A sequence model elaborates a use case and describes the interaction between the objects in a sequence over a period of time. Sequence model conceptualizes the interaction between the objects by displaying the exchange of messages between them over time.
The sequential model describes how the system parts interact to execute a use case and get a function done. In this section, we will be discussing, the sequence model in brief with the help of examples. So, let’s start.
Content: Sequence Model
What is Sequence Model?
Sequence model is a behavioural model which shows a sequence of behaviour shown by the system to the user to execute a particular use case. This behavioural sequence is shown by the exchange of messages between the set of objects.
The messages that are shared by the objects can be procedural calls or asynchronous signals which are useful for the execution of the particular function in the system. Sequence model can be modelled in two ways the one form is the scenario and the other and more structured form is the sequence diagram.
Scenario
Scenario the word itself defines that it includes the written description of the details of an individual function. In term of sequence model, a scenario is the series of events that occurs in order over a period of time to execute a particular functionality of the system.
Well, it depends whether a scenario includes all events of the system or only those which are invoked by the object for the execution of a particular use case.
The scenario is helpful in two ways. While modifying a system, developers can refer to the scenario as a set of sequential historical events executing the actual system. Or while developing a new system, developers refer scenario as a set of events that would be required to execute a proposed system.
To understand the concept of scenario lets take an example where the scenario is the session with an online stock broker. The sequence of events that occur during this session is enclosed in the scenario.
Now, you can discover that the scenario displayed in the figure above is a high-level interaction. As the first event of the scenario which is John Doe logs in, itself has several messages to be exchanged between the Jhon and system. Like, the system asks for user name and password, Jhon then puts the user name and password, the system verifies the identification and then allow John to log in.
But, in the early stages, developers frame the scenario at a high level and then in later stages of development they concentrate on detailing of the events. The scenario includes exchanged messages and also the operations performed by the objects
So, first, the developers discover the objects that need to interact to execute an event. Between the interacting objects, the developers have to decide who will be the sender and the receiver of the message along with the sequence in which messages will be exchanged. After all this, operations are added for the internal computation and then the scenario is turned down to the code.
The next sequence model is a sequence diagram that is far more explanatory and well-structured which we are discussing in the section below.
Sequence Diagram
We have seen that the scenario is a written description of the interaction between the set of objects and is in text format. This makes it a little difficult to recognize the sender and receiver of the message. When there are more than two objects it becomes even more difficult to identify the sender and receiver from the interacting objects.
The sequence diagram clearly displays the sender and receiver of the message and also the sequence of the messages exchanged which provide a clear vision of the interaction between them. Thereby the sequence diagram reveals how the actors interact with the system to execute all or part of the use case.
Sequence diagram has components like:
- The actor which are the entities that interact with the system or are external to the system.
- Lifeline shows the amount of time spent by an actor or system during the interaction.
- The message is the information sent by the sender to the receiver. The message is represented by a horizontal arrow in the sequence diagram where the arrowhead is towards the receiver of the message.
- Messages can be synchronous which means the sender waits for the receiver to process the sent message before proceeding further.
- Messages can be asynchronous where the sender proceeds without waiting for the receiver to complete the processing of the sent message.
The figure below shows the sequence diagram for the scenario that we have discussed above of a stock broker.
It is not compulsory that you should describe a use case in a single sequence diagram. It’s always better to show a portion of the use case, in a sequence diagram as large-scale interactions may have several independent tasks that could be combined in many ways.
So, instead of getting it messy by repeating the messages, we can implement a separate sequence diagram for each task. Like the figure below shows the sequence diagram for two independent tasks stock purchase and stock quote.
Definitely, every use case would have an exceptional condition for which a separate sequence diagram should be implemented. Like the sequence diagram below shows the exceptional case where a purchasing of the stock fails.
Advantages of Sequence Model
The advantages of sequence mode are as follow:
- Sequence model figures out the interaction between the user and system considering the time parameter.
- Sequence model eases the developers to understand the complicated functions of the proposed system or to document the existing system.
- Sequence model models the logic of complicated function in a graphical representation.
- Sequence model shows details the user and system interaction.
Key Takeaways
- Sequence model elaborates the uses case.
- Sequence model describes the communication between the set of objects.
- Sequence diagram expresses the high-level interaction.
- Sequence model is of two kinds scenario and sequence diagram.
- The scenario is the written description of the events generated by the objects.
- A sequence diagram shows the participation of each actor in the interaction.
- Sequence diagram displays the interaction by the exchange of messages between the sender and receiver.
- Sequence diagram displays the exchange of messages in an order in which they are exchanged.
So, this is all about the sequence model which helps the developers to understand the requirements of the proposed model and also helps the developers to document the already existing system.
Leave a Reply