These are a type of UML diagrams that show how objects in a system or classes within code
interact with each other. Especially these diagrams show interactions in the order they take
place, in a nutshell they show the sequence of events.
These diagrams are primarily used by Developers and Business professionals to understand
requirements for a new system or to document an existing process. These diagrams are
occasionally known as event diagrams or event scenarios.
Benefits:
- It is used to capture dynamic behaviour of a system.
- It is used describe the message flow of a system.
- It is used to describe the structural arrangement of the objects.
- It is used to describe the collaborate among objects.
Drawbacks:
- They are good at describing performance but they do not define it.
- They typically do not show all the iteration and control that is needed to give a
computationally absolute description
How to draw a sequence diagram?
1st we must identify – Objects taking part in the interaction.
2nd Message flows among the objects
3rd The sequence in which the messages are flowing
4th Object organisation
Notations –
The five main elements that make up a sequence diagram are activation boxes, actors,
lifelines, messages, and objects
Actor : indicates a role played by a user or any other system that work together with the
subject.
Objects: UML Object symbol illustrates of a class or of classes.
Lifeline: A lifeline, indicates an objects existence over time, it is symbolized by vertical
dashed lines.
Message: are arrows that symbolize communication between objects.
Type of arrow indicates types of messages:
- Synchronous message: solid arrow with a solid head.
- Asynchronous message: solid arrow with a stick head.
- Create message: Dotted arrow with a stick head.
- Delete message: solid arrow with a X.
- Self message: U shaped arrow.
- Return message: dashed arrow with stick head.
Activate Bar: it is used to specify the time an object needs to complete the task it is illustrated
by a thin rectangle on the lifeline
Why use sequence diagrams? Why not code it?
1. A good sequence diagram is still above the level of the real code (not all code is
drawn on diagram)
2. Sequence diagrams are language-agnostic (can be implemented in many different
languages)
3. Non-coders can read and write sequence diagrams.
4. Easier to do sequence diagrams as a team.
5. Can see many objects/classes at a time on same page (visual bandwidth).