hi, wondering is there any relation between sequence diagram and class diagram ? as what i know on sequence diagram is showing the sequence events that happen in between objects, would it means we have to include all the objects in sequence diagram to class diagram as well ? thank you and please correct me if i wrong
Joined: Jan 29, 2002
There definitely is a relation between sequence and class diagrams.
Think of class diagram as explaining the structure of the model and the sequence diagram explaining the behavior of the model.
The vertical lines in the sequence diagrams represent instances of the objects that you have in your model. The classes of these instances are typically represented in the class diagram as well to show their relations to other objects.
Thus, if you have a horizontal line going from one object to another object in a sequence diagram, you would also see a relation in the class diagram between the same two objects.
Originally posted by Alvin chew: wondering is there any relation between sequence diagram and class diagram ? as what i know on sequence diagram is showing the sequence events that happen in between objects, would it means we have to include all the objects in sequence diagram to class diagram as well ?
Well, the relation between sequence diagrams and class diagrams is that they're both UML diagrams. That's about it.
Sequence diagrams describe the dynamic aspect of your design, i.e. which object invokes which methods of which other objects in which order, while class diagrams describe the static aspect of your design, i.e. which class inherits which and which classes have associations to which other classes.
Also, I'd really encourage you to not think of such rules as "have to ... all ..." because design is not supposed to be a bureaucratic act to satisfy corporate policy. It's supposed to help you get stuff done.
Originally posted by Lasse Koskela: Well, the relation between sequence diagrams and class diagrams is that they're both UML diagrams. That's about it.
To clarify my position on this, I'm not trying to say Sathya's wrong in any way. I just wanted to stress that there isn't a "strong" link between the two kinds of diagrams even though there of course is a relation if the two diagrams are being used to describe the same design.
Joined: Jul 11, 2001
Actually there is a variant of the Fusion methodology which uses UML and has very formal rules such as "if you have a method call from an instance of A to an instance of B in a sequence diagram, there needs to be an association from A to B in the class diagram".
In my limited experience, the biggest effect this has is that it makes the design more rigid - simply because just making a very small change results in *a lot* of work. It might be intellectually satisfying, but simply doesn't provide enough value to be a reasonable practice in commercial projects.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Jan 29, 2003
Sathya was very careful and precise in using "object" and "class". Following that closely may help see how the static and dynamic views of the system are complementary.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi