UML Elements : Sequence Diagram
In the Unified Modeling Language, the sequence diagram is the name that has been given to the Message Sequence Chart. The sequence diagram will be responsible for showing various processes or elements that exist together simultaneously, and it will often be represented by parallel vertical lines.
The sequence diagram may also be represented by horizontal arrows, as well as the messages that will be sent among them, and in the category in which these messages are transferred. The sequence diagram allows for the creation of various runtime events in a graphical way. For example, you may have a UML diagram that defines message sequences of a basic system.
If you are the owner of a restaurant, you may have a diagram which shows a customer ordering food/drinks, consuming the drinks and the food, and then paying for the meal. The diagram may show dotted lines which point downward, and these could be used to represent the time frame. With the sequence diagram, time will go from the top to the bottom. The arrows will be used to denote messages from one object to other objects, and these messages may be called stimuli. As an example, when the customer in your restaurant pays for his/her meal, they may send a message called "pay" to the person who takes their money.
With a sequence diagram, you may see half arrows, and these are used to denote method calls that are asynchronous. For UML 2.0, the sequence diagram will support a notation which is similar to UML 1.0. However, it will have additional support for various modeling methods that are connected to the basic flow of events. To fully understand the power of the sequence diagram, it is important for you to understand what comprises it. This will require you to understand the various parts that make up the sequence diagram, and I will go over these various parts below.
Sequence Diagram Parts
The sequence diagram is an element that is used primarily to showcase the interaction that occurs between multiple objects. This interaction will be shown over a certain period of time. Because of this, the first symbol that is used is one that symbolizes the object. A lifeline will generally be generated, and it is a dashed line that sits vertically, and the top will be in the form of a rectangle. This rectangle is used to indicate both the instance and the class. If the lifeline must be used to denote an object, it will be underlined. If you don’t fill in the name of the instance, the blank space may be used to represent various instances which are anonymous.
To showcase an interaction, messages will be used. These messages will come in the form of horizontal arrows, and the messages should be written on top of the arrows. If the arrow has a full head, and it’s solid, it will be called a synchronous call. If the solid arrow has a stick head, it will be an asynchronous call. Stick heads with dash arrows are used to represent return messages. In addition to UML 1.0, this feature is also true for UML 2.0. The activation boxes, which may also be known as method call boxes, are rectangles which are opaque. They will be drawn on the top of a lifeline, and this will be used to denote procedures which are being carried out as a result of the message.
Objects will also be given the ability to call methods upon themselves, and they can add net activation boxes. Because of this, they can communicate with others to show multiple levels of processing. Whenever an object is eradicated or erased from memory, the "X" will be drawn at the lifeline’s top, and the dash line will not be drawn beneath it. This will often occur as a result of a message. If a message is sent from the outside of the diagram, it can be used to define a message that comes from a circle that is filled in. Within a UML based model, a Superstep is a collection of steps which result from outside stimuli. Now that I’ve gone over the sequence diagram and what comprises it, I will next talk about the Use Case Diagram.
Many developers feel that the sequence diagram is one of the most powerful aspects of the Unified Modeling Language. Once you understand the various parts that make up sequence diagram, you can fully realize the its power.