Exercise 2.3: Creating the PiggyBank domain model diagram

In this exercise, you create the Account Operations functional area and the PiggyBank domain model diagram. The domain model diagram describes the domain of the PiggyBank system by using a class diagram that shows the main classes in the system.

The analysis model builds on the Account Operations functional area that you identified in Module 1. The Account Operations package contains the Account Operations Analysis Elements subpackage, as well as the Display Balance, Transfer Money, and Cash Check use case realizations. The Account Operations Analysis Elements subpackage contains the Rational Unified Process® (RUP®) analysis elements that you create when you model the static structure of the model. The package also contains the Account Operations analysis elements diagram, which is used as a workspace for creating the domain level diagrams.

The domain diagram is a type of class diagram that shows the main classes of the PiggyBank online banking system. The simple class diagram shows the main classes that you identified in the previous exercise, the attributes of the classes, and any relationships between the classes. The domain model describes only the domain of the system, and does not describe any details of the application itself. The domain model accomplishes this by modeling only the entity classes of the system and their relationships. The domain diagram is called static, because it models only the structure of the system. In this exercise, you create the entity classes and model their attributes. You identify and model the operations of each entity when you create the sequence diagram for each use case.

Modeling is an iterative process. Your domain model changes as you discover more information about the system that you are modeling. In this tutorial, you outline the basic domain diagram and you model all of the attributes for each entity.

Creating a functional area

Because the analysis model builds on the use case model, the Account Operations functional area stores the PiggyBank analysis elements and the use case realizations. You must create a new Account Operations functional area in the root of the model.

To create the Account Operations functional area:
  1. In the Model Explorer view, expand Analysis Model, expand «ModelLibrary» Analysis Building Blocks, right-click the ${functional.area} package; then click Copy.
  2. Right-click the root Analysis Model package; then click Paste.
  3. Right-click ${functional.area}; then click Find/Replace
  4. In the Find what field, type ${functional.area} and click Replace.
  5. In the Replace with field, type Account Operations and click OK.

To add the Display Balance use case realization to the Account Operations functional area:
  1. In the Model Explorer view, expand Analysis Model, expand «ModelLibrary» Analysis Building Blocks, right-click the ${use.case} package; then click Copy.
  2. Right-click the Account Operations package; then click Paste.
  3. Right-click ${use.case}; then click Find/Replace.
  4. In the Find what field, type ${use.case} and click Replace.
  5. In the Replace with field, type Display Balance and click OK.
To add the Transfer Money use case realization to the Account Operations functional area:
  1. In the Model Explorer view, expand Analysis Model, expand «ModelLibrary» Analysis Building Blocks, right-click the ${use.case} package; then click Copy.
  2. Right-click the Account Operations package; then click Paste.
  3. Right-click ${use.case}; then click Find/Replace.
  4. In the Find what field, type ${use.case} and click Replace.
  5. In the Replace with field, type Transfer Money and click OK.
To add the Cash Check use case realization to the Account Operations functional area:
  1. In the Model Explorer view, expand Analysis Model, expand «ModelLibrary» Analysis Building Blocks, right-click the ${use.case} package; then click Copy.
  2. Right-click the Account Operations package; then click Paste.
  3. Right-click ${use.case}; then click Find/Replace.
  4. In the Find what field, type ${use.case} and click Replace.
  5. In the Replace with field, type Cash Check and click OK.

The Account Operations functional area contains the use case realizations and the analysis elements for the PiggyBank analysis model. The Account Operations Analysis Elements subpackage contains all analysis elements for the project. You can use the Account Operations Analysis Classes class diagram as a workspace to build the PiggyBank domain diagrams.

Creating the domain model diagram

You create the domain model diagram in the Account Operations functional area, and then copy the visualized model elements into the «perspective» Overviews package of the analysis model template. The Account Operations Analysis Classes diagram is the workspace for creating diagrams, while the «perspective» Overviews package contains only the final copy of the diagrams, and not the classes.

To create a domain diagram:
  1. In the Model Explorer view, expand Analysis Model and expand Account Operations.
  2. In the Account Operations Analysis Elements package, double-click Account Operations Analysis Classes.

You have created the PiggyBank Analysis Elements diagram. This diagram is a workspace in which you can create and visualize classes within the structure of the functional area. You should create your domain-level class diagrams in this package, and then drag the complete diagrams into the «perspective» Overviews package to complete the model.

Creating the Account class

The account class represents the PiggyBank user account. The account class describes the functional tasks that are associated with the account class such as getBalance and findForCustomer.

To model the Account class:
  1. In the Palette, double-click Class and name the class Account.
  2. In the diagram editor, click the Account class and, in the Properties view, on the Stereotypes page, click Add Stereotypes .
  3. In the Apply Stereotypes window, select the Entity check box, and click OK.
  4. In the diagram editor, right-click the Account class; then click Add UML > Attribute and name the attribute balance.
  5. In the diagram editor, in the Account class, click the balance attribute and, in the Properties view, on the General page, click Select type.
  6. In the Select Element window, expand UML2, click Integer and click OK.
  7. In the diagram editor, right-click the Account class; then click Add UML > Attribute and name the attribute number.
  8. In the diagram editor, in the Account class, click the number attribute.
  9. In the Properties view, on the General page, click Select type
  10. In the Select Element window, expand UML2, click String and click OK.
You have modeled the Account class.
Note: The Analysis Model template contains empty classes that are stereotyped using the RUP analysis element stereotypes. Instead of creating new classes and applying stereotypes to them, you can copy the analysis elements into your functional area and rename them. To use the existing RUP analysis elements, in the Model Explorer view, in the «ModelLibrary» building Blocks package, right-click an analyis element; then click Copy. Right-click your functional area; then click Paste.

Creating the Transfer class

The Transfer class describes the transaction that occurs when a customer transfers money from one account to another. The Transfer class has two associations to the Account class.

To model the Transfer class:
  1. In the Palette, double-click Class and name the class Transfer.
  2. In the diagram editor, click the Transfer class and, in the Properties view, on the Stereotypes page, click Add Stereotypes .
  3. In the Apply Stereotypes window, select the Entity check box, and click OK.
  4. In the diagram editor, right-click the Transfer class; then click Add UML > Attribute and name the attribute amount.
  5. In the diagram editor, in the Transfer class, click the amount attribute.
  6. In the Properties view, on the General page, click Select type.
  7. In the Select Element window, expand UML2, click Integer, and click OK.

You have modeled the Transfer class.

Modeling the Transfer-Account relationships

The Transfer class depends on the Account class.

To model the Transfer-Account relationships:
  1. In the Palette, beside Dependency, click the down arrow and click Usage.
  2. In the diagram editor, place the cursor over the Transfer class and drag it to Account class.

You have modeled the relationships of the Transfer class. Your diagram should look similar to the following figure:

The Account and Transfer relationships.

Creating the Check class

The Check class describes a check that is cashed at the PiggyBank.

To model the Check class:
  1. In the Palette, double-click Class and name the class Check.
  2. In the diagram editor, click the Check class.
  3. In the Properties view, on the Stereotypes page, click Add Stereotypes.
  4. In the Apply Stereotypes window, select the Entity check box, then click OK.
  5. In the diagram editor, right-click the Check class; then click Add UML > Attribute and name the attribute amount.
  6. In the diagram editor, in the Check class, click the amount attribute.
  7. In the Properties view, on the General page, click Select type.
  8. In the Select Element window, expand UML2; click Integer and click OK.
  9. In the diagram editor, in the Check class, click the amount attribute.
  10. In the Properties view, on the General page, beside Visibility, click public.
  11. In the diagram editor, right-click the Check class; then click Add UML > Attribute and name the attribute reference.
  12. In the diagram editor, in the Check class, click the reference attribute.
  13. In the Properties view, on the General page, click Select type.
  14. In the Select Element window, expand UML2, click String and click OK.
  15. In the diagram editor, in the Check class, click the reference attribute.
  16. In the Properties view, on the General page, beside Visibility, click public.

You have modeled the Check class. Your diagram should look similar to the following figure:

The check class showing two attributes: amount and reference.

Modeling the Check-Account relationships

The Check class depends on the Account class.

To model the Check-Account relationships:
  1. In the Palette, click Usage.
  2. In the diagram editor, place the cursor over the Check class and drag it to the Account class.

You have modeled the relationships of the Check class.

Creating the Customer class

The Customer class describes a PiggyBank customer.

To model the Customer class:
  1. In the Palette, double-click Class and name the class Customer.
  2. In the diagram editor, click the Customer class.
  3. In the Properties view, on the Stereotypes page, click Add Stereotypes.
  4. In the Apply Stereotypes window, select the Entity check box, and click OK.
  5. In the diagram editor, right-click the Customer class; then click Add UML > Attribute and name the attribute loginId.
  6. In the diagram editor, in the Customer class, click the loginId attribute.
  7. In the Properties view, on the General page, click Select type.
  8. In the Select Element window, expand UML2, click String and click OK.
  9. In the diagram editor, in the Check class, click the loginId attribute.
  10. In the Properties view, on the General page, beside Visibility, click public.
  11. In the diagram editor, right-click the Check class; then click Add UML > Attribute and name the attribute name.
  12. In the diagram editor, in the Check class, click the name attribute.
  13. In the Properties view, on the General page, click Select type.
  14. In the Select Element window, expand UML2, click String and click OK.
  15. In the diagram editor, in the Check class, click the name attribute.
  16. In the Properties view, on the General page, beside Visibility, click public.

You have modeled the Customer class.

Modeling the Account-Customer relationships

The Account class is dependent on the Customer class.

To model the Account-Customer relationships:
  1. In the Palette, click Usage.
  2. In the diagram editor, place the cursor over the Account class and drag it to Customer class.

You have modeled the relationships of the Customer class. You also completed the basic outline of the domain diagram. Your diagram should look similar to the following figure:

The basic outline of the PiggyBank domain diagram.

The diagram models the basic domain of the system by describing the structure of the main classes of the system and the relationships that exist between them. For example, a customer, who is identified by a unique login ID and name, can own more than one account, but an account cannot belong to more than one customer.

Creating the domain model overview diagram

You now create the PiggyBank domain model diagram in the «perspective» Overviews package. This is the final version of the diagram that provides overview and navigation information.

To create the PiggyBank domain overview diagram:
  1. In the Model Explorer view, expand Analysis Model, expand «perspective» Overviews, right-click ${project} Domain Model; then click Find/Replace.
  2. In the Find what field, type ${project} and click Replace.
  3. In the Replace with field, type PiggyBank and click OK.
  4. Double-click the PiggyBank Domain Model diagram.
  5. In the Model Explorer view, expand Account Operations, and expand Account Operations Analysis Elements.
  6. In the Model Explorer view, click the Customer analysis element and drag it into the diagram.
  7. In the Model Explorer view, click the Account analysis element and drag it into the diagram.
  8. In the Model Explorer view, click the Transfer analysis element and drag it into the diagram.
  9. In the Model Explorer view, click the Check analysis element and drag it into the diagram.

You have created the PiggyBank domain model diagram in the «perspective» Overviews package. This is the final version of your diagram. You can use the Account Operations Analysis Classes diagram as a rough workspace in which to create the use case participants diagrams.

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