How to Model Alternative Execution in Sequence Diagram
What are sequence diagrams and what are they used for?
Sequence diagrams are one of the 14 diagram types that can be created using the Unified Modeling Language (UML). UML diagrams are generally used when designing software and databases to make sure that the system will work as required and to reveal potential problems before building the final product.
A sequence diagram models the interactions between objects in a system in sequential order over time. Sequence diagrams can also be called event diagrams or event scenarios. The diagram shows how objects in the system exchange messages and which objects are active at any particular time.
Each object is shown at the top of the diagram and each has a lifeline that descends vertically from its center. This lifeline represents the object’s existence in the time period being captured. Horizontal arrows show the messages exchanged between the objects. An activation bar is a thin rectangular box that is shown on an object’s lifeline when it is active and processing a task. During this period it is said to have focus of control. Messages can go back and forth from left and right, with the sequence moving from top to bottom as the time period progresses.
Make your own UML sequence diagram with Gleek.
Sequence diagrams have traditionally been used to model interactions between computer systems, but they are increasingly used to document interactions between business objects. Business analysts can use them to model how a business currently works – by mapping out the interactions between personnel completing a task – to understand how orders are processed, or to clarify the steps involved in creating a product. This can help identify bottlenecks and streamline processes. Sequence diagrams can also be created by stakeholders to communicate requirements to developers.
Check out the best sequence diagram tools list.
What are sequence diagram fragments?
A fragment in a sequence diagram is a rectangular frame drawn over part of the diagram. They represent conditional structures that affect the flow of messages. These frames are known as combined fragments in the UML specification and the container is known as the interaction operand. The frame is labeled in the top-left corner. This label is known in UML as the interaction operator.
Let’s look at three of the most common fragments: option, alternative, and loop.
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. For instance, a customer is presented with the option to choose gift wrapping when completing a purchase. The customer will either select gift wrapping or not.
A guard condition is optional for option fragments. Guards in UML let you check to make sure that certain conditions have been met before activating the option, such as whether the product in the online store is suitable for gift wrapping. Guard conditions are shown in square brackets at the top of the fragment frame. They are usually Boolean expressions that correspond to true or false, but in the case of the loop fragment, they can be more complex, as we’ll see a little later on.
The alternative fragment models the classic if-then-else programming statement. The interaction operator is alt. In this fragment, the flow of messages depicts a mutually exclusive choice between two paths. The process flows along either one or the other path. For instance, the customer completing the purchase will either choose to pay by card or by wire transfer, not both.
An alternative combination fragment will have guard conditions that are tested against each possible operand. In our example, it might be the case that not every product can be purchased with a wire transfer.
What does a loop fragment represent?
So that’s an option and alternative fragments, but what about when you need to model something that needs to repeat a number of times? That’s when you use a loop fragment.
Loop fragments were introduced in UML 2 with other combined fragments and they enable you to model a repetitive sequence, along with some handy guard conditions to control the loop. The loop fragment looks much the same as the option fragment. You have the frame and the operator in the top-left corner. The interaction operator is, as you might expect, loop. For instance, a cashier entering items to be purchased into a point of sale system or a cash register may need to enter multiple items for each customer before presenting the customer with the total amount and requesting payment. So the entry of items acts as a loop fragment in the process.
19 views
505
152
6 days ago 00:52:27 0
Awakened Christ Consciousness: The Hidden Message of Jesus Revealed
6 days ago 00:04:21 0
Getting Pregnant after 36 | Best ways to Natural Conception without IVF and IUI- Aasha Ayurveda
6 days ago 00:04:14 0
How EVIL VITALITY Really Plays CS2
7 days ago 00:09:32 0
Making a Teddy Bear Keychain with Hair Rubber Bands and Sewing Thread / Incredibly Simple Steps
1 week ago 00:10:38 19
Rear Choke Submission! | Jena Bishop v Ekaterina Shakalova | Full Fight | PFL WT 6 2025
1 week ago 00:04:24 1
CryptoPromo – The Leading Crypto Marketing Platform in 2025?
1 week ago 00:00:24 0
The Most Adorable Monster in Japanese History
1 week ago 00:03:15 0
The Wallet Gesture and Invitation by Pastor Lance Edminster 2025 06-29
2 weeks ago 00:12:59 0
Americans Invented a New Christianity: Here’s Why That’s Terrifying
2 weeks ago 00:03:55 12
English Christian Song | “Those Who Are Not Acknowledged by God“
2 weeks ago 00:00:30 2
hadama #funnyclip #baby
2 weeks ago 00:04:35 10
Jeff Bezos’ $10M Venice Wedding: Inside the Lavish Celebration & Celebrity Guest List | NEWSDRIFT
2 weeks ago 00:12:56 0
Google’s AI Found a Glitch in Reality — And It’s Getting Worse
2 weeks ago 00:00:34 1
Background suppression optical sensor! High sensitivity, strong stability, handle any environment.
2 weeks ago 00:03:02 0
CryptoPromo – How to Market a Crypto Project in 2025 (Step-by-Step Guide)
2 weeks ago 00:14:02 1
DIY Puffy Boxy Quilted Patchwork Travel/ Makeup Bag Swing Tutorial
2 weeks ago 00:07:36 1
P Diddy Darts Eyes at Federal Prosecutor as She Rips Him in Closings
2 weeks ago 00:35:25 0
Теория Большого Взрыва — убита Джеймсом Уэббом?
2 weeks ago 00:00:13 0
My Home’s ’Luxury Feel’ Secret: Wood Blinds Are This Beautiful!
2 weeks ago 00:52:26 1
WWII: The Secret Financial Deal That Kept Hitler in Power - Historical Documentary - AMP
2 weeks ago 00:13:32 1
Surprising Way to Support Your Liver and Lose Fat!
2 weeks ago 00:07:47 0
The World’s First Flying Humanoid Robot
2 weeks ago 00:30:59 1
Шью детское лоскутное одеяло. Одеяло за час. Лоскутное шитье, остатки в дело. Пэчворк.
2 weeks ago 00:06:49 0
Tutorial: How to make your first edit in Liquipedia