In this post I will show an example of a use case and how to create it. Remember that use cases comes in many detail levels (See overview of Use Case Levels), in this example I will show you a Level2 use case which for example does not specify GUI requirements, error messages and confirmation messages.
Creating a use case specification has three steps:
- Create a use case model showing the use cases and actors
- Create an overview of the steps (content) of the use case -> here I strongly recommend you to use a model based approach – I prefer creating activity diagrams
- Write the use case specification
Ad 1)
In order to give you a fairly simple example I have created a very simple use case model containing only one use case:
From the use case model you can see that the system has one use case only (for simplicity) and that the use case interacts with the actor System Administrator.
Ad 2)
The next thing to do is to create an overview of what goes on inside the use case. That is, what activity steps it contains. The best way to do this is to create an activity diagram (UML notation). The activity diagram is shown below. The advantage of creating an activity diagram is that you will get an overview and be forced to consider validations and error situations.
Ad 3)
Now that you have a use case model and an overview of the steps inside the use case you are dealing with – next thing to do is to write the use case specification. The use case specification will be based on the activity diagram. The main purpose of the use case specification is to specify any pre-conditions that must be met in order to start the use case, specify any business rules related to the use case steps, and specify any post-conditions that will be present after executing the use case.
Especially the business rules are important, since the business rules specify your business requirements. For each step in the use case you need to relate the step to a number of unique business rules – the approach is shown below (as you can see step 20 relates to three business rules (FR1, FR2, FR3):
Below you can see the final use case specification (the specification is a simplified example). You can also Download Use Case Example - Create User and/or Download Activity diagram - create user (Visio drawing).
Use Case Specification
Use Case ID: UC-01
Use Case Name: Create User
Company: AllAboutRequirements.com
Project: AllAboutRequirements.com
Revision history:
Date |
Version |
Author |
Description |
23-09-2011 |
Draft |
John Hansen |
Draft example use case. |
|
|
|
|
|
|
|
|
Table of Contents
High-level Description. 3
Use Case Characteristic. 3
Activity Diagram.. 4
Outlined main scenario. 5
Outlined Alternative Scenario 1. 5
Business Rules. 6
High-level Description
The purpose of this use case is to create a new user in the system.
Use Case Characteristic
Primary Actor |
System Administrator |
Trigger |
System administrator chooses “Create User” |
Pre-conditions |
|
Post-conditions |
If success:
If failure:
|
Activity Diagram
Outlined main scenario
Step |
User (System Administrator) |
System |
Business Rules |
10 |
Screen1: Create User |
|
|
20 |
Type-in user details |
|
FR1, FR2, FR3 |
30 |
Save |
|
|
40 |
|
Validate user details |
FR4, FR5 |
50 |
|
Create user |
FR6, FR7 |
60 |
|
Grant privileges |
FR8 |
70 |
Screen3: Confirmation |
|
|
Outlined Alternative Scenario 1
|
Exit criteria from main flow: 40 |
User details validation fails |
|
Step |
User (System Administrator) |
System |
Business Rules |
10 |
Screen2 Error message |
|
|
20 |
|
|
|
Business Rules
ID |
Business Rule name |
Business Rule Description |
FR1 |
User details |
It must be possible to specify the following details when creating a new user:
|
FR2 |
Specify related department |
It must be possible to specify that the user to be created belongs to one of the following departments:
|
FR3 |
Permissions |
It must be possible to specify the following permissions to the system:
|
FR4 |
Mandatory details |
The following fields are mandatory and must be filled-in:
|
FR5 |
No duplicates |
It must be validated that the user with duplicate information (as specified in mandatory fields) does not exist. |
FR6 |
Apply employee number |
The user to be created must be created with a unique four digit employee number |
FR7 |
Apply default password |
The user to be created must be created with a default 8 character password |
FR8 |
Grant permissions |
The user to be created is granted the privileges as specified in FR3
|
Comments