Chapter 5 Building Dynamic Diagrams


Sequence Diagram Basics

The sequence diagram is a UML interaction diagram. It represents the chronology of the passing of messages between system objects and actors. It may be used to illustrate a possible scenario of a use case, the execution of an operation, or simply an interaction scenario between classes of the system.

You can use one or more sequence diagrams to enact a use case or to identify all the possibilities of a complex behavior.

A sequence diagrams conveys the same kind of information as a collaboration diagram, except that it concentrates on the chronology of messages passing between the objects in place of their structure.

A sequence diagram shows actors, objects (instances of classes) and the messages sent between them. By default, PowerDesigner provides an "interaction frame", which surrounds the objects in the diagram. Messages can originate from or be sent to any point on the interaction frame, which acts as the exterior of the system (or part thereof) being modeled, and these gates can be used in place of actor objects. For more information about using the interaction frame in this way, see Messages and gates.

One of the major advantages of a sequence diagram over a collaboration diagram is that you can reference common interactions and easily specify alternative or parallel scenarios using interaction fragments. Thus, you can describe in a single sequence diagram a number of related interactions that would require multiple collaboration diagrams.

Example


In the example above, the Client actor places an order. The Place Order message creates an Order object. An interaction fragment handles various possibilities for checking the order. The Account object and Manager actor may interact with the order depending on its size. Once the Confirm Order message is sent, the Process Order interaction is initiated. This interaction is stored in another sequence diagram, and is represented here by an interaction reference.

Analyzing a use case

A sequence diagram can be used to refine a use case behavior or description. This approach is useful during requirement analysis because it may help identify classes and associations that did not emerge at the beginning.

You can formalize the association between the use case and the sequence diagram by adding the diagram to the related diagrams list of the use case. For more information, see the "Defining related diagrams" section, in the "Working with Object-Oriented models" chapter.

It is often necessary to create several diagrams to describe all the possible scenarios of a use case. In this situation, it can be helpful to use the sequence diagrams to discover all the pertinent objects before trying to identify the classes that will instantiate them. After having identified the classes, you can then deduce the associations between them from the messages passing between the objects.

Analyzing a class diagram

Building a sequence diagram can also be the opportunity to test a static model at the conception level; it may represent a scenario in which classes from the class diagram are instantiated to create the objects necessary to run the scenario.

It complements the class diagram that represents the static structure of the system by specifying the behavior of classes, interfaces, and the possible use of their operations.

A sequence diagram allows you to analyze class operations more closely than a collaboration diagram. You can create an operation in the class of an object that receives a message through the property sheet of the message. This can also be done in a collaboration diagram, but there is more space in a sequence diagram to display detailed information (arguments, return value, etc) about the operation.

 


Copyright (C) 2006. Sybase Inc. All rights reserved.