Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between alt and opt fragment in sequence diagram?

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?

like image 316
ettozyame Avatar asked Feb 21 '14 16:02

ettozyame


People also ask

What is Alt fragment in sequence diagram?

The alternative combination fragment is used when a choice needs to be made between two or more message sequences. It models the “if then else” logic. The alternative fragment is represented by a large rectangle or a frame; it is specified by mentioning 'alt' inside the frame's name box (a.k.a. fragment operator).

What is optional fragment?

Option and alternative fragments The option fragment represents a simple choice of behavior between two options. The interaction operator is opt. The sequence fragment modeled will either occur or it will not occur, based on a particular condition.

How do you write an alt in a sequence diagram?

Select Alt. Press on the blank area of the diagram and drag to cover the Person and ATM Machine lifeline. Draw a message from ATM Machine lifeline to Person lifeline in the upper compartment of the alternative combined fragment. Name it as Ask for password.

What are the three types of frames used on a sequence diagram?

What are three types of frames used on a sequence diagram? - Alt frame: notation on a sequence diagram showing if-then-else logic. - Loop frame: notation on a sequence diagram showing repeating messages. 16.


3 Answers

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.

example of alt and opt sections in the sequence diagram

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.

like image 110
Roman Konoval Avatar answered Oct 13 '22 03:10

Roman Konoval


Alt is alternative flow (SWITCH or if. IF with two paths) Opt is IF with one flow. If you use Opt, code will be executed or not !

like image 23
Vladimir Avatar answered Oct 13 '22 04:10

Vladimir


UML - sequence diagram alt vs opt

alt - if else
opr - single condition

enter image description here

like image 7
yoAlex5 Avatar answered Oct 13 '22 02:10

yoAlex5