Exercise 2.8: Creating the Transfer Money sequence diagram

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

The Transfer Money 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 static information.

The Transfer Money sequence diagram shows the steps that occur when the user clicks Transfer Money on the main menu. The sequence diagram models the use case participants as lifelines and models the data flow as messages to indicate the workflow of the use case. When you model the workflow of the use case in a sequence diagram, you discover the operations that exist in each class. You complete the Transfer Money participants diagram as you discover and create the operations in the Transfer Money sequence diagram.

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

Creating the Transfer Money 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» Transfer Money, expand «use case realization» Transfer Money - Basic Flow and double-click the «use case realization» Transfer Money - Basic Flow diagram.
  2. In the Model Explorer view, expand Use Case Model and in the Account Operations package, click the Customer actor and drag it into the diagram.
  3. In the Model Explorer view, in the Account Operations Analysis Elements package, click the MenuForm class and drag it to the right of the Customer lifeline.
  4. In the Model Explorer view, in the Account Operations Analysis Elements package, click the TransferMenuForm class and drag it to the right of the MenuForm lifeline.
  5. In the Model Explorer view, in the Account Operations Analysis Elements package, click the TransferMoneySummaryForm class and drag it to the right of the TransferMenuForm lifeline.
  6. In the Model Explorer view, in the Account Operations Analysis Elements package, click the TransferMoneyControl class and drag it to the right of the TransferMoneySummaryForm lifeline.
  7. In the Model Explorer view, in the Account Operations Analysis Elements package, click the Account class and drag it to the right of the TransferMoneySummaryForm lifeline.
  8. Click the Account lifeline and, in the Properties view, on the General page, name the lifeline debit.
  9. In the Model Explorer view, in the Account Operations Analysis Elements package, click the Account class and drag it to the right of the debit:Account lifeline.
  10. Click the Account lifeline and, in the Properties view, on the General page, name the lifeline credit.
  11. In the Model Explorer view, in the Account Operations Analysis Elements package, click the Transfer class and drag it to the right of the credit:Account lifeline.

You have created the lifelines of the Transfer Money sequence diagram. The lifelines represent the participants that you identified in the Transfer Money Participants diagram. The lifelines are organized sequentially and are arranged with the primary message-initiating classes on the left side of the diagram. Note that the Account participant occurs twice in the diagram. One Account lifeline represents the account that is being debited, the other Account lifeline represents the account that is being credited.

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 Transfer Money 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 diagram editor, click anywhere.
  4. In the Enter Operation Name window, name the message select Transfer Money.
You modeled the Transfer Money menu item, which corresponds to the select Transfer Money operation on the MenuForm class. When you created the message, you were prompted to select an option from the Create New Operation list. When you typed select Transfer Money, you added a new operation to the MenuForm class.

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 TransferMoneyForm lifeline.
  3. In the Enter Operation Name window, name the message display.

To create the fill in and submit message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the Customer lifeline and drag it to the TransferMoneyForm lifeline.
  3. In the Properties view, on the General page, name the message fill-in and submit.

To create the transfer message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the TransferMoneyForm lifeline and drag it to the TransferMoneyControl lifeline.
  3. In the Enter Operation Name window, name the message transfer (debit, credit, amount ).

To create the withdraw message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the TransferMoneyControl lifeline and drag it to the debit:Account lifeline.
  3. In the Enter Operation Name window, name the message withdraw ( amount ).

To create the deposit message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the TransferMoneyControl lifeline and drag it to the credit:Account lifeline.
  3. In the Enter Operation Name window, name the message deposit ( amount ).

To create the «create»\CalledOperation\ message:
  1. In the Palette, beside the Asynchronous Message click the down arrow and click Create Message.
  2. In the diagram editor, click the TransferMoneyControl lifeline and drag it to the Transfer lifeline.

To create the setDebitAccount message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the TransferMoneyControl lifeline and drag it to the Transfer lifeline.
  3. In the diagram editor, click anywhere.
  4. In the Enter Operation Name window, name the message setDebitAccount ( debit ).

To create the setCreditAccount message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the TransferMoneyControl lifeline and drag it to the Transfer lifeline.
  3. In the diagram editor, click anywhere.
  4. In the Enter Operation Name window, name the message setCreditAccount ( credit ).

To create the setAmount message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the TransferMoneyControl lifeline and drag it to the Transfer lifeline.
  3. In the diagram editor, click anywhere.
  4. In the Enter Operation Name window, name the message setAmount ( amount ).

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

You have modeled the Transfer Money sequence diagram. The diagram shows the sequence of steps that occurs when the user clicks Transfer Money on the main menu. When the customer clicks Transfer Money, a form is displayed on the screen. The customer then fills out the form. The form data is sent to the TransferMoneyController class, which sends a message with the withdraw transaction information to the debit:Account class. The TransferMoney class then sends the deposit transaction information to the credit:Account class. The TransferMoneyController class creates the Transfer object and passes it the debit, credit, and amount information so that it can execute the transaction. A message is then displayed to the user. Your diagram should look similar to the following figure:

The Transfer Money sequence diagram.

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

The Transfer Money Participants diagram.
Note: Because the Transfer Money sequence diagram contains only one data flow, you can delete the «use case realization» Transfer Money - 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» Transfer Money - Alternative Flow n package; then click Delete from Model.

To continue, proceed to Exercise 2.9: Creating the Cash Check participants diagram.

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