Getting Started with UML Sequence Diagrams

You model the exchange of messages for a system with a UML sequence diagram. You can subsequently add other UML elements to the same diagram.

You can create a UML sequence diagram by adding elements from the component palette. Alternately, you can connect an empty diagram to the JDeveloper debugger and step though Java code, during which sequence diagram elements will be added automatically.

The layout of elements on a UML sequence diagram is significant, and will be determined automatically as far as possible. Object lifelines will be placed at the same level vertically, unless they are created by another object lifeline, in which case they will placed one level lower. Synchronous and asynchronous messages are placed in time order down the page.

For information about the UML notation used to represent the elements on a sequence diagram, see How to Read a UML Sequence Diagram. For more information about creating a UML sequence diagram, see Creating a UML Sequence Diagram.

Object Lifelines

You add object lifelines to a diagram by clicking on the Object Lifeline object lifeline icon, and then clicking on the diagram where you want to add the object lifeline. An edit box opens for you to enter a local identifier for the object. You can add the name of the class represented by the object by clicking on the colon in the top of the object box. You can also add a classifier by right-clicking on the object lifeline and choosing Attach Classifier, which opens a list of elements from which you choose the one you want associated with the object lifeline. Another way to attach a classifier is to drag the classifying object from the navigator onto the object lifeline. The last two methods are confirmed by the appearance (in the top left of the object lifeline) of an icon representing the classifying element.

Activations and Synchronous Messages

You add a synchronous message (and the activations at each end of it, if appropriate) by clicking on the Message Message icon, then clicking on the vertical dashed line or activation that is the starting point for the message, and then on the vertical dashed line that is the destination of the message. You can open an edit box for the text of the message by clicking on the message line and then clicking inside the gray box that appears.

The starting point and destination point of a synchronous message can be the same object lifeline, in which case you have created a self call.

Synchronous messages are depicted on the sequence diagram by solid lines with filled arrowheads.

Creation Messages

Before you add a creation message, you must already have added an object lifeline for the object that the message will create.

You add a creation message by clicking on the Creation Message Creation message icon, then on the originating object, then on the object that will be created. The rectangle and dashed line that represents the object to be created is shifted down the page relative to the originating object. You can open an edit box for the message name (for example, "new") by clicking on the message line and then clicking inside the gray box that appears.

Stop Messages

Before you add a stop message, you must already have added an object lifeline for the object that the message will delete.

You add a stop message by clicking on the Stop Message Stop message icon, then on the originating object, then on the object that will be deleted. If you start and end the stop message on the same object, you will create a self-deleting object. The activation at the end of a stop message is shown with a large cross through it. You can open an edit box for the message name (for example, "close") by clicking on the message line and then clicking inside the gray box that appears.

Return Messages

You can add a return message for any synchronous message on a sequence diagram.

You add a return message by clicking on the Return Return icon, then on an end activation, then on the corresponding start activation. You will not be able to end this return message line on any other object. The return message is depicted by a dashed line with a filled arrowhead. You can open an edit box for the text of the message by clicking on the message line and then clicking inside the gray box that appears.

Asynchronous Messages

You add an asynchronous message (and the activations at each end of it, if appropriate) by clicking on the Async Message Asynchronous message icon, then clicking on the vertical dashed line or activation that is the starting point for the message, then on the vertical dashed line that is the destination of the message. You can open an edit box for the text of the message by clicking on the message line and then clicking inside the gray box that appears.

The starting point and destination point of an asynchronous message can be the same object lifeline, in which case you have created a self call.

Asynchronous messages are depicted on the sequence diagram using stepped lines and stick arrowheads.

Dependencies

A typical use of a dependency line in a UML diagram would be to show where changes to the definition of one element may cause changes to another element.

The dependency line is a general UML diagram feature.

You can add a dependency line to a sequence diagram by clicking on the Dependency Dependency icon, then on the originating object, and then on the destination object. You can open an edit box for text describing the dependency by clicking on the dependency line and then clicking inside the gray box that appears. Dependencies are represented by dashed lines with stick arrowheads.


About UML Sequence Diagrams
Creating a UML Sequence Diagram
How to Read a UML Sequence Diagram
Modeler's Guide