02 UsecaseModel
02 UsecaseModel
Requirement Modeling
Assoc. Prof. TRAN Minh Triet
Department of Software Engineering
Introduction to Requirement Process
Problem Space
Problem
Problem
Needs
Test Procedures
Design User
Doc
2
Definitions
❖ Requirement
A condition or capability to which the system must conform.
❖ Requirements management
A systematic approach to:
3
What Do Software Requirements Specify?
Inputs Outputs
System
Design Constraints
Functions
Non-Functional
Requirements
(E.g. Performance)
(E.g. Environments)
4
UML in Context of Requirement Modeling
Business Use-
case Modeling
System Use-
case Modeling
5
Use-case Modeling
6
Objectives
7
Use cases involve a shift in thinking
8
What Is Use-Case Modeling?
Use case 1
Actor 2
Use case 2
Use case 3
Use Case 2
Specification
9
A Use-Case Model is Mostly Text
The System
Use case 1
Use-Case-Model Survey Actor 1
- survey description
- list of all actors Actor 2
Use case 2
- list of all use cases
Use case 3
Actor 3
Actor
Someone/something outside the
system, acting in a role that
Actor interacts with the system
Use case
Use Case Represents something of value
that the system does for its actors
11
Actor
Actor
12
What Is a Use Case?
performed by a system
to an actor.
13
Use cases contain software requirements
14
Capture a use-case model
15
Use-case specification
▪ Preconditions
▪ Postconditions
▪ Special requirements
▪ Key scenarios
▪ Subflows
16
Use-case diagram
17
Use cases drive software development
Use-Case Model
Realized by Verified by
Implemented
by
Design Model
Test Model
Implementation
Model 18
Benefits of use cases
19
Who should care about use cases?
❖Analysts
❖Customers
❖Users
❖Software architects
❖Designers
❖Testers
❖Project managers
❖Documentation writers
20
Requirements management process
Outline
Use Cases
Detail a Use Case
21
Review
❖What is an actor?
❖What is a use case?
❖What are some of the benefits of using use cases?
❖What is a use-case model?
❖What is a use-case diagram?
❖What is a use-case specification?
❖How does use-case modeling fit into the requirements management
process?
❖How does use-case modeling fit into the software development
lifecycle?
22
Use-case Model
23
Objectives
24
Process of writing use cases
Close Registration
Find use cases Brief description: This use case allows a Registrar to
close the registration process. Courses that do not have
enough students are cancelled. The Billing System is
notified for each student in each course that is not
cancelled, so the student can be billed.
Find actors
Important Note:
Use case writing is an iterative process
Find use cases
Outline a
use case
Detail a
use case
26
Process of writing use cases
Find actors
Name and briefly describe the
actors that you have found
Outline a
use case
Detail a
use case
27
Actors and the system boundary
Financial
Analyst
Order Entry System ? ?
Accounts
Receivable Financial
System Analyst
28
Actors and roles
29
Find actors
30
Name the actor
Patron Clerk
Bank
System
31
Describe the actor
Name Librarian
Brief description A person who adds a resource into a
library
Relationships with
use cases
Add Resource
Librarian
32
Review
33
Process of writing use cases
Find actors
Name and briefly describe the
use cases that you found
Create a use-case diagram
Find use cases Assess business values and
technical risks for use cases
Outline a
use case
Detail a
use case 34
Find use cases
GOAL 1
Actor GOAL 2
35
Find use cases (cont.)
36
Is Log in a use case?
❖By UML definition, log in is not a use case, because it does not
produce results of value to an actor.
❖However, in many cases, there is a need to capture log in separately
because it:
Captures more and more complex behaviors (security,
Log in
User
37
CRUD Use Cases
Create a schedule
Delete a schedule
38
Name the use case
Student
40
Checkpoints for actors
41
Checkpoints for use cases
42
Checkpoints for use cases (cont.)
✓ The use cases have unique, intuitive, and explanatory names so that
they cannot be confused at a later stage. If not, change their names.
✓ Customers and users understand the names and descriptions of the
use cases.
✓ The brief description gives a true picture of the use case.
✓ Each use case is involved with at least one actor.
✓ No use cases have very similar behaviors or flows of events.
43
Use-case diagrams: communicates-association
Use Case
Actor 2 Actor 3
44
Each communicates-association is a whole dialog
Register for
Student Courses Course
Catalog
System
45
Use-case diagram example
Course Catalog
System
Student
Select Courses
Professor to Teach
46
Review
47
Relating Use-case
❖ We explore:
Concepts.
Notation.
Practice.
48
Relating Use Cases
Extends.
Generalization-specialization.
49
Includes
Borrow Renew
Resources «in Membership
»
des
clu
clu
des
«in
»
Check
Privileges
50
Includes (continued)
❖ When a super-task use case (base use case) uses a subtask use
case (an abstract use case).
An abstract use case is a factored-out subtask that does not
stand on its own as a complete, separate process.
❖ In the use-case text, the base use case explicitly initiates the
abstract use case.
“initiates” is a verb favored by some use case writers.
Use Case: Borrow Resources
...
Step 5. Initiate use case Check Library Privileges
...
51
Includes (continued)
❖ When to use?
When several use cases share a common subflow that can be
factored out.
When a use case is too complex and needs factoring into
52
Extends
Borrow Renew
Resources Membership
«extends»
«extends»
«e
xt
en
ds
»
53
Extends (continued)
❖ When a second use case extends the story of the first use case.
“Chapter 1 followed by Chapter 2.”
54
Extends (continued)
❖ The second use case can extend the first at its end or at any point -
the extension point.
❖ The second use case might unconditionally extend the first or only
under some condition.
❖ In the use case text of the second, it notes (in the Cross Reference
section) that it extends the first.
▪ Use Case: Return Resources
▪ Cross-References: Extends use case Borrow Resources
▪ ...
55
Extends (continued)
❖ When to use?
To add new possible postflows to a complete use case.
56
Generalization-Specialization
❖ “… to add a more specific use case that inherits and adds features
to (a more general use case).”
«includes» Arrange
Pay Fine
Payment
Arrange
Pay by Cash Credit
57
Generalization-Specialization (continued)
❖ Example:
▪ Use Case: Pay Fine
▪ ...
▪ Step 3. Initiate use case Arrange Payment
▪ …
▪ --------------------------------
▪ Use Case: Arrange Payment
▪ Step 1. Collect payment
▪ Step 2: Verify payment
▪ Step 3: Record payment
58
Generalization-Specialization (continued)
--------------------------------
59
Exercise 2: Finding actors and use cases
60
Process of writing use cases
Find actors
Outline the flow of
events
Find use cases Capture use-case
scenarios
Collect additional
Outline a requirements
use case
Detail a
use case 61
Outline each use case
62
Why outline use cases?
DRAFT
Use-Case Size
Is it more than
one use case?
? ?
Outlining helps find
alternative flows
Use Case
?
63
Flows of events (basic and alternative)
Odd cases
64
Outline the flows of events
❖ Basic flow
What event starts the use case?
❖ Alternative flows
Are there optional situations in the use case?
65
Step-by-step outline: Register for Courses
Basic Flow
1. Student logs on.
2. Student chooses to create a schedule.
3. Student obtains course information.
4. Student selects courses.
5. Student submits schedule.
6. System displays completed schedule . What are other
Alternative Flows alternatives?
A1. Unidentified student.
A2. Quit.
A3. Cannot enroll.
A4. Course Catalog System unavailable.
Can we allow students to register if the Course
Catalog is unavailable?
A5. Course registration closed.
66
What is a use-case scenario?
Flow
Scenario
Note: This diagram illustrates only some of the
possible scenarios based on the flows.
67
Why capture use-case scenarios?
68
How to capture use-case scenarios
❖ Example:
Use Case: Register for Courses
Scenario: Quit before registering
Flows: Basic Flow, Quit
69
Outline: Register for Courses
71
Collect additional requirements
72
What Is an Activity Diagram?
Flow of Events
This use case starts when the Registrar requests that the
system close registration.
73
What Is an Activity?
individual actions.
❖ May contain boolean expression constraints when the activity is
invoked or exited
Activity 2
<<Precondition>> Activity 4
Boolean constraint
<<Postcondition>>
Activity 5 Boolean constraint
74
Example: Activity Diagram
Decision
Select Course Activity/Action
Concurrent
Threads [ delete course ]
Delete Course
[ add course ]
Synchronization
Bar (Fork)
Check Check
Guard Schedule Pre-requisites
Condition
Synchronization
[ checks completed ] [ checks failed ] Bar (Join)
Update
Schedule
75
Review
76
Exercise 3: Outlining use cases
77
Process of writing use cases
Find actors
Detail the flow of
events
Find use cases Structure the flow of
events
Specify additional use
Outline a case properties
use case
Detail a
use case 78
Detail a use case
You found actors and use cases, then outlined the use cases. Next, you
add detail.
<Use-Case Name>
1. Brief Description
2. Basic Flow of Events
3. Alternative Flows
4. Subflows
5. Key Scenario
6. Preconditions Add Detail
7. Postconditions
8. Extension Points
9. Special Requirements
10. Additional Information
79
Use case style
For readability
80
Detail the basic flow of events
Register for Courses
Structure the 1.1 Basic Flow
flow into steps 1. Log On.
This use case starts when someone accesses the
Course Registration System and chooses to register for
courses. The system validates that the person accessing
the system is an authorized student.
Number and 2. Select “Create a Schedule ”.
title each step The system displays the functions available to the
student. The student selects “Create a Schedule ”.
3. Obtain Course Information.
The system retrieves a list of available course offerings
Describe the from the Course Catalog System and displays the list to
steps the student .The student can search the list by
department, professor, or topic to obtain the desired
course information .
4. Select Courses.
The student selects four primary course offerings and
two alternate course offerings from the list of available
offerings course offerings.
…
81
Phrasing of steps
82
Structure the use-case flows
83
Cross-referencing using a label
1. Student Logs On
84
Review: Flows of events (basic and
alternative)
Odd cases
85
Detail of Alternative Flows
Alternative Flows Describe what
happens
2.8 Unidentified Student.
In the Log On step of the Basic Flow, if the system
Location
determines that the student identification information is
not valid, an error message is displayed, and the use
case ends.
2.9 Quit and Save. Condition
At any time, the system will allow the Student to quit. The
student chooses to quit and save a partial schedule
before quitting. The system saves the schedule, and the Actions
use case ends.
2.10 Waiting List
In the Select Courses step of the Basic Flow, if a course
the Student wants to take is full, the systems allows the
Resume
student to be added to a waiting list for the course. The location
use case resumes at the Select Courses step in the Basic
Flow.
86
Visualize behavior
87
Subflows
Alternative
Flows Subflow
88
Example subflow
89
Preconditions
❖ Describe the state that the system must be in before the use case
can start
Simple statements that define the state of the system, expressed
Precondition:
The list of course offerings for the semester has been created
90
Postconditions
❖ Describe the state of the system at the end of the use case
Use when the system state is a precondition to another use
case, or when the possible use case outcomes are not obvious
to use case readers
Should never refer to other, subsequent use cases
91
Sequence use cases with pre- and
postconditions
92
Other use case properties
❖ Special requirements
Related to this use case, not covered in flow of events
❖ Extension points
Name a set of places in the flow of events where extending
93
RUP style summary
RUP Use-Case Specification
Template
❖Basic flow
Steps are numbered and named
Steps do not reference alternative
flows
Shows the main actor succeeding
in that actor’s main goal
❖Alternative flows
Have names
May have steps
94
Use case checkpoints
95
Review
96
Guidelines for when to use Use cases
97
What is NOT a use case
❖Functional decomposition
❖User interface specification
❖System design specifications
98
Functional Decomposition
system.
▪ Often do not make sense in isolation.
❖ Use cases:
Are NOT functional decomposition.
system.
Provide context.
99
Functional Decomposition: An Example
Bank
Consortium
100
Avoid Functional Decomposition
101