This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Class or interaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Class or interaction" Watch "Class or interaction" New topic

Class or interaction

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

Does the class diagram come first or the sequence?

Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
In which context???

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
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
I often find myself switching between class and sequence diagrams during initial design. First I try to gather the most important classes on the paper, then validate the class diagram by drawing the most important interactions into sequence diagrams, enrichen the class diagram, draw some more sequence diagrams, etc.
So, based on this I'd say class diagram comes first but neither one is "finished" first.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
I agree that in that case they should be done concurrently - if at all. You should also think about alternatives. If I remember correctly, Robert C. Martin suggests using collaboration diagrams instead of sequence diagrams - because the dynamic structure is much more important than the sequence of messages in most cases.
Another technique to consider are CRC cards - they allow for a much more dynamic exploration of possibilities than diagrams.
And when doing test driven development, I find that most often I don't see value in interaction diagrams. A roughly sketched class diagram suffices, if I need it at all.
Raj Waters
Ranch Hand

Joined: Apr 21, 2002
Posts: 37
After the Use Case is modelled, it is matter of choice to use Class Diag. OR Seq Diag. Depending upon the application analysis you may like to consider first sequence diag. and then may be class diag. OR both can be designed concurrently.
The goal is to capture the behaviors
- Raj

- Raj<br />[MCSE, SCJP, SCWCD]
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Raj Waters:
The goal is to capture the behaviors

Well, the primary goal is to get enough understanding of the problem and its solution to be able to start coding the latter. Emphasis on *start*! has some very good thoughts on the subject.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I have that chart by Scott Ambler on my wall just to shock people who are walking by. Everybody here made good points - use whatever model works, use a bunch at once, use neither. My own style is to use collaboration earlier and sequence later. They are two views into exactly the same underlying model and Rose can even transform either one into the other. Collaboration tends to expose more structure and sequence more logic.

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
I agree. Here's the link:
subject: Class or interaction
Similar Threads
can non-static inner class access any member
andrew has wii
Doubt about diagram class
WA #1.....word association
Doubt about diagram class (realization)