So far, we have seen a few structural diagrams such as the use case diagram which is great for visualising Actors in a system and what they do. Figure below shows a use case diagram for a Library system which shows what a Librarian Actor can do with the system.
Another structural diagram is the class diagram which shows the overview of the classes in a system which shows what values need to be stored and how the classes are related including generalisation and composition relationships. Figure 3.4 below shows a class diagram for a Purchasing system.
Class Diagram for Purchasing System
But these diagrams are not great for representing say, how objects actually interact with one another. We will now look at sequence diagrams which model how the system behaves when it is run, in a visual way. Sequence diagrams are dynamic diagrams which show how different objects change and how they communicate with each other using messages.
Elements of a Sequence Diagram
The main elements in a sequence diagram are objects, object lifelines, object activations and messages.
a. Objects
Objects represent an Actor or Object that interacts in the system. Usually, the Actor initiates the interaction and may be omitted from the diagram. Objects are rectangles that you see horizontally across the top of the diagram.
b. Object Lifelines
Reference: https://www.omg.org/spec/ UML/2.5/About-UML/
c. Object Activations
d. Messages
A message is what the sender wants the receiver to do. The message has a name and an argument list which are the information that the receiver needs to do the work. The message is therefore methods of the class in the receiver object