It is easy to mix up the definitions of use case and use case scenario. A use case represents the actions that are required to enable or abandon a goal. A use case has multiple “paths” that can be taken by any user at any one time. A use case scenario is a single path through the use case. This article provides an example use case and some diagrams to help visualize the concept.
An Example Use Case
Most example use cases are very simple. Unfortunately, a simple use case does not help get a clear understanding of the differences between a use case and a use case scenario. For this article, please refer to the sample use case provided in yesterday’s article.
This use case involves 17 steps in the normal flow, and three alternate flows that represent another 10 steps. The details of each step are provided in prose in the previous article. To understand the difference between a use case and a use case scenario, we can look at visualizations of the use case, drawn as a flow chart. As a reader commented earlier today, an activity diagram would be a “better” artifact than a flow chart. This is true, but this article will use flow charts, as they require no “additional” learning for most readers. Activity diagrams can be used, if that is your preference.
Diagramming The Normal Flow
The example use case includes 17 steps in a normal flow that involves the system being developed, and three actors (two of whom are other systems). The actors are the user, the fulfillment system, and the billing system. The actions of the system being developed are represented in the “System” swim lane. You can see that control flows from the user to the system and back again, and occasionally from the system to external systems and back again.
Diagramming Alternate Flows
The alternate flows can also be diagrammed using the same approach.
Each alternate flow is drawn in this example with different colored arrows (red, green, or blue) in order to present an alternative visualization of the flow of the use case.
Simpler Visualization Of A Use Case
The essence of the diagram, for the purpose of discussing use case scenarios, is the branching behavior. You can create a much simpler diagram like the following:
The normal flow is represented as a straight line from the solid black circle to the “END” object. Each alternate flow is represented as a curved line that breaks away from the normal flow. The “3A1″, and “5A2″ alternate flows return to the normal flow (bypassing one or more normal flow steps). The “5A1″ alternate flow returns to a step in the middle of the 3A1 flow. The “10A1″ flow has one or more steps that end in the use case being abandoned.
The colors have been added only to simplify the mapping of this diagram to the cross-functional flowchart above. If anyone knows of a formal name for this type of diagram, please add it in the comments.
Use Case Scenarios
The use case is represented graphically as the following diagram.
The diagram depicts every possible branch of the use case that might be executed in either the completion or abandonment of the goal of the use case. The use case may take any of the alternate flow branches or may follow the normal flow.
A use case scenario is a single path through the diagram.
This diagram shows the normal flow – one of the possible scenarios.
Another possible scenario would be to follow alternate flow “3A1″ and otherwise follow the normal flow. The simple diagram would look like the following:
Specifically, this diagram indicates the following path as shown in the cross-functional flow chart:
Finding All Use Case Scenarios
The next step is a somewhat mechanical exercise – identifying all of the possible use case scenarios for a single use case.
The user can take alternate “3A1″ or not, and then can take either “5A1″ or “5A2″ (in either case), or both “5A1″ and “5A2″, and then can either take alternate “10A1″ or not. This yields 12 distinct scenarios. You could arguably consider that taking “5A1″ multiple times is a valid scenario.
A use case defines all of the paths that lead to the success of the use case. The use case also defines all of the paths that lead to the abandonment of the use case without achieving its goal. Each unique combination of those paths that can be taken by an actor during a single “pass” through the use case is a use case scenario.