Sequence Diagrams

A sequence diagram is an easily comprehensible visualization of single scenarios or examples of business processes with regard to their behavior in time. It focuses on when the individual objects interact with each other during execution. The diagram essentially includes a timeline that flows from the top to the bottom of the diagram and is displayed as a dotted line. The interaction between objects is described by specifying the different kinds of messages sent between them. Messages are called stimuli. They are displayed as arrows; the diverse arrowheads stand for different kinds of messages (see below).

The following diagram shows a typical example:

Figure 7-13. A Sequence diagram.

Objects

After creating or changing objects, they are automatically arranged in the Diagram pane. You can specify which of the objects is to have control by enabling the corresponding check box 'Focus of control' in the Properties tab. Afterwards, you'll see how the graphical representation of this object changes: it gets a thick border and its lifeline is no longer a dashed line but a solid rectangular area.

Self messages

In Poseidon, all stimulus types, except create stimuli, can be created as self stimuli. In the case of a stimulus to itself, the arrow starts and finishes on the object's lifeline. A self stimulus is created by dropping the stimulus target point on the source object.

Selecting an operation

A call stimulus is regarded as a procedure call and can be connected with any operation provided by the receiving object, depending on its type. This is achieved by connecting the stimulus with an action that will cause the class operation to be called. The following two figures show an example for selecting an operation and attaching actual arguments to the call.

Figure 7-14. Selecting the action of a stimulus in a sequence diagram.

After selecting the stimulus in the diagram, the Details pane shows the properties of the stimulus. It is there that you have to open the dispatched action field displayed in the Details pane, which is directly below the name field of the stimulus. This causes the Details pane to change the view to the properties of the action.

Figure 7-15. Selecting an operation and attaching arguments to it.

The properties of the action allow you to select an operation and edit the arguments attached to the procedure call. The set of possible operations includes all operations of the receiving object's class, as well as any operations inherited from direct and indirect superclasses or interfaces. If an operation is selected, the name of the action is updated according to the name of the operation and the given values of the arguments. An empty argument value is displayed as an 'x'. Keep in mind that you cannot edit the name field while an operation is selected.

Activations

An activation shows the period of time during which an object will perform an action, either directly or through a subordinate procedure. It is represented as a tall thin rectangle with the top aligned with its point of initiation and the bottom aligned with its point of completion.

Now, let's consider how Poseidon deals with starting and terminating activations. When an object receives a stimulus, an activation is created that starts at the tip of the incoming arrow. When an object sends a stimulus, an existing activation is terminated at the tail of the outgoing arrow. There are two exceptions: First, an outgoing send stimulus does not terminate an existing activation, because it represents an asynchronous message. Second, if an object has explicitly set the focus of control, its activation will continue during the whole lifetime.

Notes on Sequence Diagrams

Diagram Elements

Toolbar

Select

Object

Call Stimulus

Create Stimulus

Destroy Stimulus

Send Stimulus

Return Stimulus

Note

Connect comment to element

Text

Circle

Rectangle

Polygon

Polyline

Repaint