How to Include Conditions in UML Sequence Diagrams

sequence-diagramuml

I like to draw a UML sequence diagram to display the sequence of actions and interactions of different parts of my system (I think they called actors).

However, I need to include if then else statements here. Do I do something wrong? Can I use conditional if statements in my UML sequence diagram? How?

Best Answer

As in many types of UML diagrams, you can use guards to denote a condition. A guard is a boolean expression that you can write over a transition.

Here's a picture with an example: enter image description here

Notice the "[pastDueBalance = 0]" condition.

You can also use combined fragments for more complicated conditional logic. See this nice msdn article for further information.