I want to know in detail about the difference between alt and opt fragment in sequence diagram, they seem similar, I can't distinguish them. Anyone knows about this thing?
alt
is used to describe alternative scenarios of a workflow. Only one of the options will be executed.
opt
is used to describe optional step in workflow.
For example, for online shop purchase sequence diagram you may use opt
to describe how user can add gift wrapping if she wishes. alt
may be used to describe two variants of payment: using credit card or wire money transfer.
In UML specification the meaning is described in section 17.12.15. opt
and alt
are two different operator types and here's how specification describes them:
alt
:
The InteractionOperatorKind alt designates that the CombinedFragment represents a choice of behavior. At most one of the operands will be chosen. The chosen operand must have an explicit or implicit guard expression that evaluates to true at this point in the interaction. An implicit true guard is implied if the operand has no guard.
opt
:
The InteractionOperatorKind opt designates that the CombinedFragment represents a choice of behavior where either the (sole) operand happens or nothing happens. An option is semantically equivalent to an alternative CombinedFragment where there is one operand with non-empty content and the second operand is empty.