Exercise 2.6: Creating the Display Balance sequence diagram

In this exercise, you create the Display Balance sequence diagram. The Display Balance sequence diagram shows the workflow of the functional task.

The Display Balance Participants diagram models the structure of the classes in the Display Balance functional task. The diagram also shows the relationships that exist between each class; however, it does not describe the workflow of the functional task. The use case realization relies on a sequence diagram to describe this dynamic information.

The Display Balance sequence diagram shows the steps that occur when the user clicks Display Balance on the main menu. The diagram models the use case participants as lifelines and models the data flow as messages to indicate the workflow of the use case. The sequence diagram describes the dynamic information that is necessary to understand the temporal flow of data. When you create the sequence diagram, you discover all the operations in each class in the use case.

Modeling a system is an iterative process. You can modify your sequence diagram at any time as you discover the details of the system. In this tutorial however, you create the complete Display Balance sequence diagram.

Creating the Display Balance sequence diagram and lifelines

Before you can model the workflow, you must first model the lifelines of the sequence diagram. The use case participants form the lifelines of the sequence diagram.

To create the sequence diagram and lifelines:
  1. In the Model Explorer view, expand Account Operations, expand «use case realization» Display Balance, expand «use case realization» Display Balance - Basic Flow and double-click the «use case realization» Display Balance - Basic Flow diagram.
  2. In the Model Explorer view, expand Use Case Model.
  3. In the Account Operations package, click the Customer actor, and drag it into the diagram.
  4. In the Model Explorer view, in the analysis model, in the Account Operations Analysis Elements package, click the MenuForm class and drag it to the right of the Customer lifeline.
  5. In the Model Explorer view, in the Account Operations Analysis Elements package, click the DisplayBalanceForm class and drag it to the right of the MenuForm lifeline.
  6. In the Model Explorer view, in the Account Operations Analysis Elements package, click the Account class and drag it to the right of the DisplayBalanceForm lifeline.

You have created the lifelines of the Display Balance sequence diagram. The lifelines represent the participants that you identified in the Display Balance Participants diagram. The lifelines are organized sequentially and are arranged with the primary message-initiating classes on the left side of the diagram.

Modeling message flow

This exercise models the message flow in the sequence diagram. Messages in a sequence diagram indicate the data flow between classes in a system.

To create the select Display Balance message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the Customer lifeline and drag it to the MenuForm lifeline.
  3. In the Enter Operation Name window, name the message select Display Balance.

To create the display message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the MenuForm lifeline and drag it to the DisplayBalanceForm lifeline.
  3. In the Enter Operation Name window, name the message display.

To create the findForCustomer message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the DisplayBalanceForm lifeline and drag it to the Account lifeline.
  3. In the Enter Operation Name window, name the message findForCustomer.

To create the getBalance message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the DisplayBalanceForm lifeline and drag it to the Account lifeline.
  3. In the diagram editor, click anywhere.
  4. In the Enter Operation Name window, name the message getBalance.

To create the loop combined fragment:
  1. In the Palette, click Loop Combined Fragment.
  2. In the diagram editor, click to the right of the getBalance message and create a box around the getBalance method.

You have modeled the Display Balance sequence diagram. The diagram shows the sequence of steps that occur when the user clicks Display Balance on the main menu. After the customer clicks Display Balance in the main menu, the MenuForm class the display operation on the DisplayBalanceForm class, which calls the findForCustomer operation on the the Account class to find the balance for the current customer. The DisplayBalanceForm class can call the getBalance operation on the Account class repeatedly to return the balance for an account. Your diagram should look similar to the following figure:

The Display Balance sequence diagram.

The Display Balance sequence diagram completes the Display Balance use case realization. You have modeled the static and dynamic information of the Display Balance functional task. If you open the Display Balance participants diagram, you notice that the diagram now contains the operations that you created as messages in the sequence diagram. The Display Balance participants diagram should look similar to the following figure:

The Display Balance participants diagram.
Note: Because the Display Balance sequence diagram contains only one data flow, you can delete the «use case realization» Display Balance - Alternative Flow n package from the Model Explorer view. This package is included in the template, but is not needed. To delete the package, in the Model Explorer view, right-click the «use case realization» Display Balance - Alternative Flow n package; then click Delete from Model.

To continue, proceed to Exercise 2.7: Creating the Transfer Money participants diagram.

Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.