Identifying Scenarios

The most important parts of a use case elaboration are the scenarios.

A scenario describes the dialog between user and the use case.

A scenario is an instance of a use case.

If we think of a use case as a function declaration, then we can think of a scenario as a function call.

Identifying Scenarios

Recall that a use case represents an actor goal.

For example the ATM "transfer funds" use case:

What are the possible scenarios?

Scenario 1: funds are successfully transferred.

Scenario 2: insufficient funds in source account

Scenario 3: source and/or destination accounts are in use (possibly because it's a joint account)

Scenario 4: invalid PIN

Scenario 5: ???

Usually the first scenario describes the situation in which the goal is accomplished. This is called the main scenario. The alternate scenarios usually describe cases in which exceptions occurred.

Scenario as a script

We can model a scenario using a script. For example, the main or success scenario for "Transfer Funds" begins by validating the account holder:

1. holder: inserts card
2. ATM:     reads card
3. ATM:     requests PIN
4. holder:  enters PIN
5. ATM:     validates PIN
6. ATM:     displays menu

Next, the user specifies that he wants to transfer a certain amount of money from a source account to a destination account:

7. holder:  selects transfer funds
8. ATM:     requests source account
9. holder:  selects source account
10. ATM:    requests target account
11. holder: selects target account
12. ATM:    requests amount
13. holder: specifies amount

Now the ATM asks the bank to transfer the specified amount from the holder's source account to his destination account:

14. ATM:    requests transfer funds
15. bank:   requests source account
16. ATM:    selects source account
17. bank:   requests target account
18. ATM:    selects target account
19. bank:   requests amount
20. ATM:    specifies amount
21. bank:   transfers funds
22. bank:   sends success
23. ATM:    displays success

The system redisplays the menu:

24. ATM:    displays menu

The insufficient funds scenario is almost the same as the success scenario except for messages 21, 22, and 23:

21'. bank:  detects insufficient funds in source account
22'. bank:  sends failure: insufficient funds
23'. ATM:   displays insufficient funds

Technically, the transfer funds success scenario consists of steps 8 through 17 in the script. The insufficient funds scenario can be thought of as a branch that breaks off from the main sequence after step 20:

14->15->16->17->18->19->20->21->22->23->24
                         |             
                        21'->22'->23'-> 24