Sequence diagram reference Class diagram

11 views
Skip to first unread message

Guk

unread,
Oct 21, 2011, 5:45:43 PM10/21/11
to UML Forum
Hi,
Hopefully a simple question. I'm creating a sequence diagram (a while
since I've done one) that describes a simple action.

I have a class diagram similar to this...

3 classes;
Owner
Car
CarOwnership - cannot exist without Owner and Car.

Owner 1 ------ 0..* CarOwnership 0..* -----------1 Car

CarOwnership enables a many:many between Owner and Car.

If I have a sequence diagram that creates the 3 classes, I think RSM
(if memory serves) only allowed messages between classes that had
associations, therefore there couldn't be a direct message between
Owner and Car. Is this right?

So basically, the seq diagram looks like..(sorry, without lifelines)

Actor Owner
CarOwnership Car
-----create------->
-----create----------->
-----
create--------------->


I'm pretty sure this was also described when I did a UML course a
while ago.

Many thanks.


H. S. Lahman

unread,
Oct 22, 2011, 11:14:35 AM10/22/11
to umlf...@googlegroups.com
Responding to Guk,

> If I have a sequence diagram that creates the 3 classes, I think RSM
> (if memory serves) only allowed messages between classes that had
> associations, therefore there couldn't be a direct message between
> Owner and Car. Is this right?

I'm afraid not. The SD only defines object collaborations and relative
sequence. It does not specify relationship navigation in the Class
Diagram. It is quite common for messages to traverse paths with multiple
associations. So the message should be shown directly between Owner and
Car since all OO collaborations are peer-to-peer.

[Relationship routing can be critical when there are relationship loops
in the Class Diagram. For many moons one of the holes in UML was the
inability to specify which path to take in a loop. Since that decision
is essentially dynamic, it should be specified in the method generating
the message. But back in the day one specified what went on in methods
in Activity Diagrams. So one thing that text-based AALs brought to the
table was the ability to specify the path rigorously with syntax like

ref = this -> A5 -> A7 -> A2 WHERE (...);
GENERATE e1 TO ref WITH ...

when they replaced ADs for specifying methods.]

AFAIK no UML drawing tool is confused about this. It has been years
since I used RSM, but I am pretty sure it allowed peer-to-peer
collaborations.

--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

Rene Descartes went into a bar. The bartender asked if he would like a drink. Descartes said, "I think not," and disappeared.

H. S. Lahman
H.la...@verizon.net
software blog: http://pathfinderpeople.blogs.com/hslahman/index.html

RJB

unread,
Oct 22, 2011, 7:44:29 PM10/22/11
to UML Forum

I have to ramble a bit to think this through.

If an object of class A creates an object of class B the create
"message" is not sent to an object of class B because it doesn't exist
yet. In a sequence chart the create goes to the head of the life line.
In a communications diagram to a metaclass called B.
In other words a classwide method or static function.

But the object that creates the new object must know what it is! And
so needs an attribute or a parameter to store the new object. If it is
an attribute then you have an association. If not you have a
dependency not an association.

I hope this helps.
RJB
Reply all
Reply to author
Forward
0 new messages