Sams Teach Yourself C++ in 21 Days

(singke) #1
This simple interaction diagram shows the interaction among a number of design classes
over time. It suggests that the ATMclass delegates to the CheckingAccountclass all
responsibility for managing the balance, while the CheckingAccountcalls on the ATMto
manage display to the user.
Interaction diagrams comes in two flavors. The one in Figure 11.21 is called a sequence
diagram. Another view on the same information is provided by the collaboration dia-
gram. The sequence diagram emphasizes the sequence of events over time; the collabora-
tion diagram emphasizes the “timeless” interactions among the classes. You can generate
a collaboration diagram directly from a sequence diagram; tools such as Rational Rose
automate this task at the click of a button (see Figure 11.22).

364 Day 11


FIGURE11.22
Collaboration
diagram.

Customer
AT M

Checking
Account

1: Check Balances

2: Get Balance

3: Display Balance

6: Print

4 : Withdraw cash

5 : Dispense

Receipt

State Transition Diagrams
As you come to understand the interactions among the objects, you also have to under-
stand the various possible statesof each individual object. You can model the transitions
among the various states in a state diagram (or state transition diagram). Figure 11.23
shows the various states of the CustomerAccountclass as the customer logs in to the
system.
Every state diagram begins with a singlestartstate and ends with zero or more end
states. The individual states are named, and the transitions might be labeled. The guard
indicates a condition that must be satisfied for an object to move from one state to
another.
Free download pdf