• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

condition clause for if-else in sequence diagram

 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Is there a UML condition clause for
if ( )
.....
else
.....
I know how to do "if" condition clause
but not "if - else".
Thanks.
JB
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can certainly do if-else branches in UML though their is not a standard way to achieve this. This is because of the flexibility inherit in UML. Just write your conditions so that they are easily recognized as being the inverse of each other.
 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if-else would not conform to UML. Right?
 
Greg Fox
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To an extent you can do this by using the following notation:
[x>10>]myMessageForFirstCase()
[x<=10]myMessageForAnotherCase()
if you need to do more elaborate cases such as multiple messages from an object based on the same conditional, then it is probably best to separate the alternatives into multiple sequence diagrams.
 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When U do this, it suggests that both conditions
are tested. It like if ... if ..., not if ... else ....
JB
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I disagree. A Sequence Diagram tells very little about the implementation. If you would like to test both conditions then that is fine, if not then it is just as good. The purpose of a Sequence or Collaboration Diagram is to show interaction between objects in a Use Case, no more, no less.
 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sequence Diagram does tell implementation details
if your diargam is for implementation. You can do reverse
engineering on classes or java files to get
sequence diagrams. But you may get if - else
that do not comform to UML. S.D. can be in three
levels: conceptual, specification, implementation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic