UML: Sequence Diagram

Joshua U
3 min readSep 25, 2021

Sequence diagram helps us to understand how objects interacts each other , emphasizes time ordering of messages. It can model simple sequential flow, branching, iteration, recursion and concurrency.

Simple sequence diagram looks like this :

Example sequence diagram

X-axis represents with objects, Y-axis represents the time. Dotted line under the objects is its life line and arrow that points to other object or self is message or it might be the condition. Below diagram gives you clear understanding :

Example sequence diagram with explanation.

Object: Object is either class or instance of the class i.e object

Syntax: [instanceName][:CLassName]

We should include instance names when objects are referred to in messages or when several objects of the same type exist in the diagram. The life line represents the object’s life during the interaction.

Messages: An interaction between two objects is performed as a message sent from one object to another i.e Simple operation call, signaling, RPC. If object obj1 sends a message to another object obj2 some link must exist between these two objects(dependency, same objects). A message is represented by an arrow between the life lines of two objects.

message representation

A message is labeled at minimum with the message name. Return values to the messages are indicated using dashed arrow like this:

return value representation in sequence diagram

Model return value only when we need to refer it. Prefer modeling return values as part of a method invocation. e.g.: ok = isValid()

Synchronous Messages: Nested flow of control, typically implemented as an operation call . The routine that handles the message is completed before the caller resumes execution.

Synchronous Messages

Object creation : An object may create another object via <<create>> message.

Creating constructor

Preferable way of creating the constructor :

Preferable way of creating constructor.

Object Destruction: An object may destroy another object via a <<destroy>> message. An object may destroy itself. Avoid modeling object destruction unless memory management is critical.

Object destruction

Control Information : condition

The message is sent only if the condition is true.

Syntax: [expression] message-label

Example:

Example for condition

Control Information: Iteration

The message is sent many times to possibly multiple receiver objects.

Syntax: * [ ‘[‘ expression ‘]’ ] message-label

Example:

Example for Iteration

The control mechanisms of sequence diagrams suffice only for modeling simple alternatives.

Sequence diagram Example 1:

Sequence diagram Example 2:

--

--

Joshua U

Python Enthusiast, Assistant Professor, Care for developing