UML Sequence Diagram Tutorial


Sequence diagrams are a popular dynamic modeling solution in UML because they specifically focus on the "lifelines" of an object and how they communicate with other objects to perform a function before the lifeline ends. Use this guide to learn everything there is to know about sequence diagrams in UML.

What is a sequence diagram in UML?

To understand what a sequence diagram is, it's important to know the role of the Unified Modeling Language, better known as UML. UML is a modeling toolkit that guides the creation and notation of many types of diagrams, including behavior diagrams, interaction diagrams, and structure diagrams. A sequence diagram is a kind of interaction diagram, because they describe how—and in what order—a group of objects works together. These diagrams are used by software developers and business people alike to understand requirements for a new system or to document an existing process. Sequence diagrams are sometimes known as event diagrams or event scenarios.

Remember that there are two types of sequence diagrams: UML ones and code-based ones. The latter is sourced from programming code and will not be covered in this guide. Lucidchart’s UML diagramming software is equipped with all the shapes and features you will need to model both.

Benefits of sequence diagrams

Sequence diagrams can be useful reference diagrams for businesses and other organizations. Try drawing a sequence diagram to:

  • Represent the details of a UML use case.

  • Model the logic of a sophisticated procedure, function, or operation.

  • See how tasks are moved between objects or components of a process.

  • Plan and understand the detailed functionality of an existing or future scenario.

Use cases for sequence diagrams

There are several scenarios that are ideal for choosing to use a sequence diagram. Some may include:

  • Usage Scenario - A usage scenario is a diagram of how your system could potentially be used. It's a great way to make sure that you have worked through the logic of every usage scenario for the system.

  • Method Logic - Just as you might use a UML sequence diagram to explore the logic of a use case, you can use it to explore the logic of any function, procedure, or complex process.

  • Service Logic - If you consider a service to be a high-level method used by different clients, a sequence diagram is an ideal way to map that out.

  • Sequence Diagram Visio - Any sequence diagram that you create with Visio can also be uploaded into Lucidchart. Lucidchart supports .vsd and .vdx file import and is a great Microsoft Visio alternative. Almost all of the images you see in the UML section of this site were generated using Lucidchart.

Basic symbols and components

To understand what a sequence diagram is, you should be familiar with its symbols and components. Sequence diagrams are made up of the following icons and elements:

 

Symbol Name Description

object Symbol

Object symbol

This box shape represents a class, or object, in UML. They demonstrate how an object will behave in the context of the system. Class attributes should not be listed in this shape.

activation box

Activation box

Symbolized by a rectangle shape, an activation box represents the time needed for an object to complete a task. The longer the task will take, the longer the activation box becomes.

actor symbol

Actor symbol

Represented by a stick figure, actors are entities that are both interactive with and external to the system.

package symbol

Package symbol

Also known as a frame, this is a rectangle shape that is used in UML 2.0 notation to contain interactive elements of the diagram. The shape has a small inner rectangle for labeling the diagram.

lifeline symbol

Lifeline symbol

A dashed vertical line that represents the passage of time as it extends downward. Along with time, they represent the sequential events that occur to an object during the charted process. Lifelines may begin with a labeled rectangle shape or an actor symbol.

option loop symbol

Option loop symbol

A rectangle shape with a smaller label within it. This symbol is used to model "if then" scenarios, i.e., a circumstance that will only occur under certain conditions.

alternative symbol

Alternative symbol

Used to symbolize a choice (that is usually mutually exclusive) between two or more message sequences. To represent alternatives, use the labeled rectangle shape with a dashed line inside.

Common message symbols

Packets of information that are transmitted between objects. They may reflect the start and execution of an operation
or the sending and reception of a signal.

 

Symbol Name Description

synchronous message Symbol

Synchronous message symbol

Represented by a solid line with a solid arrowhead. This symbol is used when a sender must wait for a response to a message before it continues. The diagram should show both the call and the reply.

asynchronous message Symbol

Asynchronous message symbol

Represented by a solid line with a lined arrowhead. Asynchronous messages are those that don't require a response before the sender continues. Only the call should be included in the diagram.

asynchronous return message Symbol

Asynchronous return message symbol

Represented by a dashed line with a lined arrowhead.

asynchronous create message Symbol

Asynchronous create message symbol

Represented by a dashed line with a lined arrowhead. These messages are sent to lifelines in order to create themselves.

reply message Symbol

Reply message symbol

Represented by a dashed line with a lined arrowhead, these messages are replies to calls.

delete message Symbol

Delete message symbol

Represented by a solid line with a solid arrowhead, followed by an X symbol. This messages indicates the destruction of an object and is placed in its path on the lifeline.

Sequence diagram examples

Sequence diagram of a hospital management system

Running a hospital requires a simple and succinct overview of the system. A hospital management system, also known as a hospital information system, is an integrated system that encompasses many aspects of hospital undertakings, including checkups, prescriptions, appointments, and information on the patients and their caretakers. The diagram below provides a simple view of how the primary processes operate with each other over time. You can use Lucidchart to reshape the diagram any way you choose and to share it with your colleagues or collaborators.

sequence diagram for hospital management system

Click here to use this template

Sequence Diagram for ATM system

An ATM allows patrons to access their bank accounts through a completely automated process. You can examine the steps of this process in a manageable way by drawing or viewing a sequence diagram. The example below outlines the sequential order of the interactions in the ATM system. You can see at a glance how the system works; just click to edit the template so it suits your own needs.

sequence diagram for an atm system

Click here to use this template

How to make a sequence diagram

In Lucidchart, creating a sequence diagram from scratch is surprisingly simple.

  1. Open a blank document or start with a template and enable the UML shape library.

  2. Select the shape you want and drag out symbols from the toolbox to the canvas

  3. Then model the process flow by drawing lines between shapes while adding text.

Dive deeper into this guide on how to draw a sequence diagram in UML for additional insight. It's easy to resize and style any element. You can even import SVG shapes and Visio files for a custom solution. If you'd like to learn more about UML, check out our What is UML tutorial.