Skip to main content

Money transfer sequence diagram questions

Short answer

Two classes (Account and Person); events: John sends xfer(m,a2), a1 calls check(), if OK a1.minus(m) and sends plus(m) to a2; check() ensures sufficient balance and account validity, preventing invalid transfers.

Based on the below diagram for model action of money transfer, answer the following questions: (a) How many numbers of classes are involved in this transfer activity? What are they? (b) What are the events followed for transfer complete? (c) Why this check( ) function is required for this transfer? [Figure: sequence diagram with lifelines a1:Account, a2:Account and John:Person. a1:Account receives the message xfer(m:Money, a2), then calls check() on itself with a return 'evaluation'; then, if [OK], calls minus(m) on itself and sends plus(m) to a2:Account.]

(a) Number of classes involved

Two classes are involved: Account (the lifelines a1:Account and a2:Account are two objects of the same class) and Person (John:Person, the actor/initiator). So there are three objects but two classes.

(b) Events followed for the transfer to complete

  1. John sends xfer(m:Money, a2) to a1:Account.
  2. a1 calls check() on itself to evaluate whether the balance is sufficient; it returns evaluation.
  3. If the result is [OK], a1 calls minus(m) on itself to reduce its balance by m.
  4. a1 sends plus(m) to a2:Account, which increases its balance by m.
  5. The transfer is complete; control returns to John.
 John:Person   a1:Account     a2:Account
     |  xfer(m,a2) |              |
     |------------>|              |
     |             |--check()-.   |
     |             |<-evaluation  |
     |             |  [OK]        |
     |             |--minus(m)-.  |
     |             |------plus(m)>|

(c) Why check() is required

check() verifies the business rule that the source account has enough balance (and is valid/active) before any money is moved. Its result (evaluation) is the guard [OK] for the following messages. Without it, a1 could be overdrawn, or money could be transferred out of an invalid or blocked account, leaving the accounts in an invalid state. Because both minus(m) and plus(m) are sent only when the guard is [OK], a failed check stops the whole transfer before any balance changes.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Object Oriented Analysis and Design chapter 2 questions →