UML - Sequence Diagram Tutorial
In UML, sequence diagrams are a subset of interaction diagrams. They're designed to show how processes interact with each other over time. This guide will teach you how to create effective sequence diagrams in Lucidchart.
Lucidchart is a simple diagramming tool with endless possibilities. You can create nearly any kind of UML diagram with our app, along with business and educational charts.Try it now Sign up free
UML can be overwhelming, so before you dive in, take a few minutes to review the basics. This page can help you understand what a sequence diagram is, and this guide to UML explores baseline concepts of the Unified Modeling Language. Once you comprehend that information, it will be much simpler to create and understand sequence diagrams.
IDENTIFY USE CASES & COMPONENTS
Sequence diagrams are surprisingly versatile. Many experts believe that they're also easier to read than other types of UML diagrams. Use sequence diagrams to:
- Display notes and details of a UML use case.
- Model interactions within a complicated process or system.
- Plan future situations that will involve a wide variety of components.
- Identify how tasks are transferred between objects in a sequence and thus, inefficiencies in the flow.
The first step to building a sequence diagram is listing relevant components. You need to identify objects, which are the most important participants in the process. Sometimes called actors, objects perform tasks and send messages back and forth. For example, an online shopping system could include several objects: customers, sales managers, and warehouse staffers. Objects don't have to be people; in this example, both the online shopping system itself and the customer's bank are participants in the diagram. These objects work together to support the final goals: to sell merchandise to a customer and provide money to the sellers. The other group of components you should identify are messages sent between objects. To find these messages, ask yourself, “What information must be conveyed in order to fulfill the process?”
ADD UML SYMBOLS
Now that you know which components are objects and which are messages, you can begin drawing. Be sure to turn the UML shape library on from inside the Lucidchart editor. Adding sequence diagram shapes to the canvas is as easy as dragging and dropping. Just pull symbols from the correct section of the shape library and remember that customization is simple. To add text—such as the name of the object—drag out a text box or click on the rectangle shape itself and start typing. Occasionally, an object is both internal and external to a system. In these cases, an actor symbol (the stick figures) is an appropriate replacement for the rectangle shape. Find it in the use case diagram section of the toolbox.
Lifelines are integral parts of sequence diagrams. These are the dotted lines that flow vertically from object symbols at the top of the chart. In Lucidchart, you can represent the flow of time in a sequence by clicking and dragging from the object shapes—lifelines will instantly appear. Line length depends on how many messages are in the sequence, since messages are placed vertically along the lifeline.
Next, you'll represent information that's sent between objects. Each piece of information is known as a message. Find the long, thin rectangle in the sequence diagram shape library—this shape is an activation box and represents a single message. Drag it onto the lifeline and resize as needed. Once it's in place, click and drag to create a message arrow. As with other elements, you can label this message by clicking and typing. Change the arrow's direction and styling from the properties bar at the top of the editor.
To learn more about sequence diagram messages, see our sequence diagram page for a detailed explanation.
If an object is destroyed during the sequence, place the large X shape on the lifeline to represent its destruction.
Keep in mind that any object can communicate with another; they don't have to be next to each other.
Continue adding shapes until each object and message is represented on the canvas. Your UML sequence diagram is complete when the last message is drawn.
Before you publish, review each step of the sequence for typos, logical errors, or notation problems. Remember that even though lifelines don't represent a set amount of time, messages should always be listed vertically and in sequential order. When you've looked over your work, share with a trusted team member or mentor to get their input.
Lucidchart is an excellent solution for nearly any type of visual communication. Try our adaptable templates for UML, including several for sequence diagrams.