Re: Polymorphic UML sequence diagrams

Re: Polymorphic UML sequence diagrams

From: Andrea Baruzzo <>
Date: Tue, 21 Nov 2006 10:18:11 +0100
Message-ID: <>
Hi Zouhaib,
if I would "translate" the scenario you are discussing into sequence
diagram, I'd show one instance of type Circle and another instance of
type Rectangular. Then I show a call of the method draw for each of
them. The fact that you use a pointer (vs. a reference or an object
instance) to access an object is an implementation detail.

If you want to show a more general polymorphic behaviour, (imho) you
should explicitly use the Shape interface to call the draw method.
Typically, in the foo procedure, you hold a list of Shape objects (or
a list of Shape* pointers, if you prefer), you retrieve the next Shape
object, then you call the method draw. In this case, the scenario
works for any Shape object.

What influences the diagram is your intention to emphasize the
interaction with any Shape object, or with a specific instance of a
Shape Hierarchy.


On 11/20/06, Zouhaib Zafar <> wrote:
> Hello all,
> I have a similar issue regarding Polymorphic UML Sequence Diagrams. I want
> to model the following scenario using a sequence diagram:
> There is a base class Shape which is derived by a class Rectangle and a
> class Circle. draw() is a (pure) virtual method in class Shape and is
> overridden in the derived classes. How would I show the method
> "foo(Rectangle r)" of class "Test" by using a sequence diagram, considering
> foo() as the initiating event of the sequence.
> class Test{
> void foo(Rectangle r){
>     Shape *p;
>     Circle c1;
>     p = &c1;
>     p->draw();
>     p = &r;
>     p->draw();
>     }
> }

Dr. Andrea Baruzzo
Laboratorio di Intelligenza Artificiale
Room SSSH, 2nd floor, Stecca Sud
UniversitÓ degli Studi di Udine,
Via delle Scienze 206, 33100 Udine
Office: +39 0432 558435
Received on Tue 21 Nov 2006 - 09:18:15 GMT