Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

break / stop execution in UML sequence diagram mid-way inside alt / opt

In a UML Sequence Diagram - If a flow should stop if a condition is met midway, how would it be best represented with alternate / optional fragments?

i.e. - If the stop condition is not met then the flow is continued for several more steps. Should the alternate fragment cover all of the steps since the stop condition, making all steps past it part of the alternate fragment, or is there a notation to handle the stop inside a small alternate fragment (confined only to the condition)?

like image 989
Ron Kuper Avatar asked Jul 10 '16 14:07

Ron Kuper


People also ask

What is Alt and opt in sequence diagram?

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.

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).

How do you end a sequence diagram?

Lifeline Start and End A lifeline may be created or destroyed during the timescale represented by a sequence diagram. In the latter case, the lifeline is terminated by a stop symbol, represented as a cross.

What does dotted line mean in sequence diagram?

Under each actor or system there are long dotted lines called lifelines, which are attached to them. Actions are performed with lines that extend between these lifelines. When an action line is connected to a lifeline it shows the interaction between the actor or system.


1 Answers

There are three options for this situation. Each of them I illustrate with a diagram showing how the respective combined fragment should be used. The actual behaviour is hidden with interaction references (normalFlow for a flow that should normally be executed and breakFlow for any flow that should happen in case of a required break).

The first solution is the most convenient one - it exactly covers your case and you can also use the positive version of a break guard. However each of them provide you a valid possibility.

  1. Break combined fragment

When a break combined fragment is met and its guard condition is true, only this fragment is still executed and then the execution of the interaction (flow) stops. If the condition is not met, the combined fragment is omitted and the normal flow continues. This is exactly the case you describe. In this case you would put the messages that shouldn't be executed in case of a break condition after the break combined fragment.

enter image description here

  1. Opt combined fragment

When an opt combined fragment is met it executes only if a guard condition is true. The rest of a flow continues regardless of the condition. You can put the part of the flow that is continued only if the break condition is not met inside the opt combined fragment. The opt fragment should have a guard that is opposite to the condition at which the flow should stop. If any additional actions should happen in case of a break, they should be put after the opt combined fragment.

enter image description here

  1. Alt combined fragment

When an alt combined fragment is met its guard conditions are evaluated and only the eventual one fragment which guard evaluates to true is executed. There might be also a situation when none of the guards evaluate to true and no fragment is executed in such case. Whatever flow is after the combined fragment is executed normally anyway. In this case you would preferably put two fragments, one with the correct operation guard and the second one with a condition that should cause a break. Put the normal flow in the first fragment and whatever should happen in case of a break in the second fragment.

enter image description here

like image 81
Ister Avatar answered Sep 30 '22 00:09

Ister