Source: UML Distilled, Third Edition by Martin Fowler (Chapter 9: Use Cases)
Use cases are a technique for capturing the functional requirements of a system. Use cases work by describing the typical interactions between the users of a system and the system itself.
A use case is a set of scenarios tied together by a common user goal. There is no standard way to write the content of a use case, and different formats work well in different cases. The following figure shows a common style to use:
We can start by writing the main success scenario as a sequence of numbered steps. Then we take the other scenarios and write them as extensions. Extensions can be successes—user achieves the goal, as in 3a—or failures, as in 6a. This structure is a great way to brainstorm alternatives to the main success scenario. For each step, we could ask, How could this go differently? and in particular, What could go wrong?
Keep in mind each step in a use case is an interaction between an actor and the system – a simple statement clearly showing 1) who is carrying out the step, 2) the intent of the actor.
A use case should not include 1) the mechanics of what the actor does, nor 2) any description of the user interface.
In the picture , the first step includes another use case “browse catalog and select items to buy.” Here underlining is used to show an included use case. There’s no standard way to show an included use case in the text. Try not to break down use cases into sub-use cases.
As well as the steps in the scenarios, you can add some other common information to a use case.
- A pre-condition describes what the system should ensure is true before the system allows the use case to begin.
- A guarantee describes what the system will ensure at the end of the use case. Success guarantees hold after a successful scenario; minimal guarantees hold after any scenario.
- A trigger specifies the event that gets the use case started.
We should work hard to keep the use case brief and easy to read. Long, detailed use cases may not get read, which rather defeats the purpose.