How to represent 'if (condition1 && condition2)' in sequence diagram

40 views Asked by At

I know alt is the equivalent of if else in UML, but how to represent a more complex condition like:

if (condition1 && condition2) else condition3 

Is it [condition1 == true]&&[condition2==true] ?

1

There are 1 answers

0
Christophe On

The guard in the operand of a combined fragment such as alt is an interaction constraint expressed between a pair of square brackets. Therefore, your condition should stay between one pair of brackets.

UML offers full flexibility about how to specify such a constraint:

The specification of a user-defined Constraint is often expressed as a text string in some language, whose syntax and interpretation is as defined by that language. In some situations, a formal language (such as OCL) or a programming language (such as Java) may be appropriate, in other situations natural language may be used.

In other words, with the guard brackets [condition1 && condition2] is perfectly fine. If you prefer OCL syntax, it would be [condition1 and condition2].