Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sequence diagram and class diagram

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sathya Srinivasan
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic