Exercise 2.10: Creating the Cash Check sequence diagram

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

The Cash Check Participants diagram models the structure of the classes in the Cash Check 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 uses on a sequence diagram to describe this static information.

The Cash Check sequence diagram shows the steps that occur when the user clicks Cash Check 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. When you model the workflow of the use case in a sequence diagram, you discover the operations that exist in each class. You can complete the Cash Check participants diagram as you discover and create the operations in the Cash Check sequence diagram.

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, you create the complete Cash Check sequence diagram.

Creating the Cash Check 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» Cash Check - Basic Flow, and double-click the «use case realization» Cash Check - Basic Flow diagram.
  2. In the Model Explorer view, expand Use Case Model, expand Account Operations, click the Teller actor, and drag it into the diagram.
  3. In the Model Explorer view, expand Account Operations Analysis Elements, click the MenuForm class, and drag it to the right of the Teller lifeline.
  4. In the Model Explorer view, in the Analysis Model, in the Account Operations Analysis Elements package, click the CashCheckForm 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 CashCheckSummaryForm class and drag it to the right of the CashCheckForm lifeline.
  6. In the Model Explorer view, in the Account Operations Analysis Elements package, click the CashCheckControl class and drag it to the right of the CashCheckSummaryForm 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 CashCheckControl lifeline.
  8. Click the Account lifeline and, in the Properties view, on the General page, name the lifeline credit.
  9. In the Model Explorer view, in the Account Operations Analysis Elements package, click the CityBank class and drag it to the right of the Account lifeline.
  10. In the Model Explorer view, expand Use Case Model, expand Account Operations, click the CityBank actor, and drag it to the right of the Account lifeline.

You have created the lifelines of the Cash Check sequence diagram. The lifelines represent the participants that you identified in the Cash Check Participants diagram. The lifelines are organized sequentially and are arranged with the primary message-initiating classes on the left side of the diagram. There are two CityBank lifelines. The first CityBank lifeline represents the CityBank banking system that is used to verify PiggyBank transactions. The second CityBank lifeline, which references the CityBank actor that you created in the use case diagram, represents the CityBank institution.

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 Cash Check message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the Teller 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 Cash Check.

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 CashCheckForm 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 Teller lifeline and drag it to the CashCheckForm lifeline.
  3. In the Properties view, on the General page, name the message fill-in and submit.

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

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

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

To create the cashCheck message:
  1. In the Palette, click Asynchronous Message.
  2. In the diagram editor, click the CityBank lifeline and drag it to the CityBank actor lifeline.
  3. In the Enter Operation Name window, name the message cashCheck ( checkReference, amount ).

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

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

You have modeled the Cash Check sequence diagram. The diagram shows the sequence of steps that occurs when the user clicks Cash Check on the main menu. When the teller clicks Cash Check, a message is sent to the CashCheckForm class, which displays a form on the screen. The teller fills out the form, which is then sent to the CashCheckControl class for processing. The CashCheckControl class searches for the account, and then sends a message that contains the transaction information to CityBank. CityBank then cashes the check. The CashCheckControl class calls the deposit method of the credit:Account class and cashes the check in the PiggyBank account. A message is then displayed to the user. Your diagram should look similar to the following figure:

The Cash Check sequence diagram.

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

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

To continue, proceed to Exercise 2.11: Documenting the analysis classes.

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