How to show "if" condition on a sequence diagram?

James Raitsev picture James Raitsev · Nov 13, 2011 · Viewed 298.8k times · Source

I was wondering, how can one represent "if" statement on a sequence diagram?

if (somethingShouldBeDone) {
       // Do it
} else {
       // Do something else
}

Can it be represented at all? The thing is ... in my code, fair amount of conditions are checked to determine a variety of actions. If i am going to show the actions, I'd like to explicitly state that actions are caused by particular events.

If possible create an image representation of a solution.

Answer

GETah picture GETah · Nov 13, 2011

If else condition, also called alternatives in UML terms can indeed be represented in sequence diagrams. Here is a link where you can find some nice resources on the subject http://www.ibm.com/developerworks/rational/library/3101.html

branching with alt