Re[2]: Polymorphic UML sequence diagrams



Re[2]: Polymorphic UML sequence diagrams

From: John Daniels <jd_at_syntropy.co.uk>
Date: Tue, 21 Nov 2006 07:35:31 +0000
Message-ID: <486796611.20061121073531@syntropy.co.uk>
Hi Zouhaib,

It's possible I'm out of touch with the latest thinking, but I've
always considered sequence diagrams to be exemplars. That is, a
sequence diagram is answering the question: "If I had this specific
set of objects connected in this specific way and one of them receives
the stimulus x what will happen?" A particular diagram covers only
that one scenario, and is in no way generic. If you adopt this way of
thinking then, clearly, there is a nearly infinite set of sequence
diagrams you *could* draw, even for a small system, but you choose to
draw those diagrams that best inform the reader about the interesting
cases.

So my answer to your question is simple: The objects you depict in
your sequence diagram would all be instances of Circle and Rectangle.
The type Shape would not appear anywhere.

--John Daniels

====
Original message
From: Zouhaib Zafar <zouhaib@hotmail.com>
Date: 20 November 2006
Time: 4:21:56 PM
Subject: Polymorphic UML sequence diagrams
----

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();
}}

Further, are all the functions considered as virtual by UML? Do the
UML specifications discuss this issue?

Kind Regards,Zohaib
Received on Tue 21 Nov 2006 - 07:36:17 GMT