Sequence diagram



A Sequence Diagram is a Unified Modeling Language (UML) diagram that shows the processes that execute in sequence. The sequence diagram shows the sequence of messages, which are exchanged among roles that implement the behavior of the system, arranged in time. It shows the flow of control across many objects that collaborate in the context of a scenario.

The UML 1.x diagram on the right describes the sequences of messages of the (simple) Restaurant System. This diagram represents a Patron ordering food and wine, drinking wine then eating the food, and finally paying for the food. The dotted lines extending downwards indicate the timeline, time flows from top to bottom. The arrows represent messages (stimuli) from an actor or object to other objects. For example, the Patron sends message 'pay' to the Cashier. Half arrows indicate asynchronous method calls.

The UML 2.0 Sequence Diagram supports similar notation to the UML 1.x Sequence Diagram with added support for modeling variations to the standard flow of events.

Parts of a Sequence Diagram
A sequence diagram generally shows the interaction between objects over the progression of time. Thus, the first symbol required is that to represent an object. More correctly, a lifeline is drawn. It is a vertically dashed line which has as its top a rectangle indicating the instance and class names in the standard UML format of instance name : class name. If the lifeline is that of an object, it is underlined (if not it is a role). Note that leaving the instance name blank can represent anonymous and unnamed instances.

In order to display interaction, messages are used. These are horizontal arrows with the message name written above them. Solid arrows with full heads are synchronous calls, solid arrows with stick heads are asynchronous calls and dashed arrows with stick heads are return messages. This definition is true as of UML 2, considerably different from UML 1.x.

Activation boxes, or method-call boxes, are opaque rectangles drawn on top of lifelines to represent that processes are being performed in response to the message.

Objects calling methods on themselves use messages and add new activation boxes on top of any others to indicate a further level of processing.

When an object is destroyed (removed from memory), an X is drawn on top of the lifeline, and the dashed line ceases to be drawn below it. It should be the result of a message, either from the object itself, or another.

A message send from outside the diagram can be represented by a message originating from a filled-in circle.