Activity Diagram Example

Use Case: Make vending machine payment

Participating actors: (none)

Preconditions: The user is part way through the purchase of an item or service.

Main flow description: The user inserts a coin or note. The vending machine deducts the value of the coin or note from the outstanding balance. The machine deduces that the amount paid now equals the balance outstanding, and displays a message saying enough money has been paid.

Postconditions – success guarantees: The remaining balance to be paid has fallen to zero.

Postconditions – minimal guarantees: (none)

DETAILED STEPS

Extension point step: (unspecified)

STEP  DESCRIPTION
1The customer inserts a coin or note
2The system computes that the coin or a note brings the outstanding balance to zero
3The system displays a message indicating the correct amount has been paid

Merge point step: (none)

Alternative path

Extension point: After insertion of a coin or note

Precondition: The amount paid has not reached the required balance

Alternative flow description: The customer is informed on the display that there is still an outstanding amount that needs to be paid.

Remerges: Back at the beginning of the make payment use case

DETAILED STEPS

Extension point step: 1

STEP  DESCRIPTION
1.1The machine displays the remaining balance to be paid following subtraction of the value of the most recently inserted note or coin.

Merge point step: 1

Alternative path

Extension point: After insertion of a note or coin

Precondition: Note or coin inserted exceeds outstanding balance

Alternative flow description: The machine determines that it has suitable change to issue a refund of the overpaid amount. The machine dispenses this change in the change tray for the customer to collect. The display shows a message telling the customer to pick up their change.

Remerges: An alternative end to the make payment use case

DETAILED STEPS

Extension point step: 1

STEP  DESCRIPTION
1a.1The machine inspects its change to see if it can pay the correct change.
1a.2The machine dispenses the correct change to the change tray.

Merge point step: (none)

Alternative path

Extension point: After an overpayment of the outstanding balance

Precondition: The machine does not have enough change to give the customer the outstanding balance

Alternative flow description: The machine prompts the user saying it does not have enough change, inviting them to abort the transaction or proceed without change being given. The customer selects proceed. The machine dispenses any change it is able to give back, this being less than the total amount due to the customer.

Remerges: Use case ends here.

DETAILED STEPS

Extension point step: 1a.1

STEP  DESCRIPTION
1a.1.1The machine informs the customer that it will not be able to give them all their change, and asks if they want to proceed anyway
1a.1.2The customer selects proceed anyway.
1a.1.3The machine dispenses what change it can into the cash tray.

Merge point step: (none)

The equivalent activity diagram

Note how the activity diagram uses the diamond branch symbols to show the extension and remerge points. The condition on each alternative path is shown as a UML condition on the branch arrow, enclosed in square brackets. The start and end of the use case are shown using the entry and exit point symbols of UML. These symbols were ‘borrowed’ by UML from Petri Net modelling.

Activity diagram for the Make vending machine payment use case