November 27, 2014
Hot Topics:

A Visual Introduction to Using UML Sequence Diagrams for Refining Object Models

  • December 23, 2008
  • By Mark Grand
  • Send Email »
  • More Articles »

Object-Oriented Design

The value of Object-Oriented Design is in allowing major structural decisions to be made before being committed to code. This allows the relationships and responsibilities of classes to be worked out efficiently and with little distraction.

The process of object-oriented design begins with an initial estimate of the classes that will be needed. The usual way to refine this estimate into a detailed object model is to work through the object interactions that are needed to support individual features or use cases.

As you discover each interaction, you add it to an interaction diagram. The most common type of interaction diagram used for this purpose is a sequence diagram. If the interaction involves a method or relationship that does not yet exist in the object mode, you either add it to the model or modify something already in the object model to accommodate the interaction.

What Is a Sequence Diagram?

UML sequence diagrams show a sequence of interactions among objects. Figure 1 shows an example of a sequence diagram.

Figure 1: Simple Sequence Diagram

This diagram shows some of the interactions among the objects involved in running a toll gate in a toll plaza. A TollManager, who is some kind of external actor, causes a TollBooth object's start operation to be called. The start operation runs asynchronously of what the TollManager is doing. You know that it runs asynchronously of what the TollManager is doing because of the open arrowhead (). This means that after initiating the start operation, the TollManager does not wait for the operation to finish; it just continues to go about its business at the same time.

The start operation repeatedly calls the TollBooth object's collectNextToll operation. You know that the calls to the collectNextToll operation are repeated indefinitely because of the asterisk ( *) that precedes the name of the operation.

The start operation's calls to the collectNextToll operation are synchronous. This means that the start operation must wait for the collectNextToll operation to finish before continuing. You know that the calls are synchronous because of the solid closed arrowhead ().

The collectNextToll operation makes a synchronous call to two other operations. It calls the TollBasket object's collectToll operation. Next, it calls the TollGate object's raiseTollGate operation.

Sequence Diagram Elements

Before moving on to the next topic, look at UML terminology for some of the elements of a sequence diagram. Figure 2 is the sequence diagram you saw previously, but with some annotations added.

Figure 2: Annotated Sequence Diagram

Stick figures represent an external actor. Boxes at the top represent an object. You know that they are objects rather than classes because the names in the boxes are underlined. Because the names in Figure 2 are preceded by a colon (:), you know that the names are the names of the class that each object is an instance of.

Below each actor and object is a dashed vertical line called a life line. Each object's and actor's life line is used to organize things that happen related to the object or actor with the earliest at the top and the latest at the bottom.

Vertical rectangles placed along a life line that are called activations. Each activation represents the running of an operation associated with the life line's actor or object.





Page 1 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel