This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes sequence diagram and class diagram Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "sequence diagram and class diagram " Watch "sequence diagram and class diagram " New topic
Author

sequence diagram and class diagram

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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

Joined: Jan 29, 2002
Posts: 379
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.


Cheers, Sathya Srinivasan - SCJP 1.2, SCWCD 1.2, SCMAD 1.0
Co-Author of Whizlabs SCMAD Certification Exam Simulator and SCMAD Exam Guide Book
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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

Joined: Jul 11, 2001
Posts: 14112
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
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sequence diagram and class diagram
 
Similar Threads
Passed PartII-III with 100%
relation between Caretaker and Orignator in Memento pattern UML representation
Sequence diagrams and Class Diagrams
what are the difference between class diagram and sequence diagram?
Rose Question, automatically create dependencies/associations from Sequence Diagram