Guard conditions in sequence diagrams

In sequence diagrams, a guard condition, also called an interaction constraint, is a Boolean conditional expression that guards an interaction operand in a combined fragment.

A guard condition contains two expressions that designate the minimum and maximum number of times that a loop combined fragment runs.

A guard condition is a semantic condition or restriction that is set in square brackets in an interaction operand in a combined fragment. When you create a combined fragment, a guard condition is created automatically. You can also manually create a guard condition in an interaction operand that does not have an existing guard condition.

A guard condition appears at the start of the interaction and contains all the information that is required to make the decision about whether to run the traces in the interaction operand. If the guard condition tests true, the traces run. Because a guard condition is optional, the interaction also runs if no guard condition is specified in the interaction operand.

The following figure illustrates how guard conditions are represented in an interaction.

This interaction frame shows two lifelines with two combined fragments crossing the lifelines. The first loop combined fragment has one interaction operand and a guard condition. The second alt combined fragment has two interaction operands, each with a guard condition.

Related tasks
Adding guard conditions to sequence diagrams

Feedback