Use Cases and Activity Diagrams

For use cases described using the casual or even the fully dressed template, it is difficult to see the big picture showing all the paths through the use case. The primary path describes just that, the primary path. In order to keep the description simple, it does not describe the extension points or branch conditions for any alternative paths that diverge from it. Similarly, each alternative path is a description of just that path. It does not show in the path description itself how it fits into the overall flow that makes up a traversal of the entire use case.

One useful diagram type from UML that does show this kind of information is the activity diagram. Being based on a flow chart, the activity diagram enhances this basic diagram type with swimlanes, parallel forks and joins, posting of and pending on signals, plus one or two other useful extensions.

An activity diagram can be generated that shows the primary path and all the alternative paths that branch off it, together with the points at which they remerge if any. As such, it is able to show in a single picture the entire functionality of the use case, in a form that is still reasonably digestible by non-technical stakeholders.

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
1 The customer inserts a coin or note
2 The system computes that the coin or a note brings the outstanding balance to zero
3 The 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.1 The 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.1 The machine inspects its change to see if it can pay the correct change.
1a.2 The 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.1 The 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.2 The customer selects proceed anyway.
1a.1.3 The 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.

Site Map | Printable View | © 2008 - 2017 Ropley Information Technology Ltd | Powered by mojoPortal | HTML 5 | CSS | Design by jQueryUI