Software Design & Architecture: Lecture # 3 Use Case Modeling
Software Design & Architecture: Lecture # 3 Use Case Modeling
Software Design & Architecture: Lecture # 3 Use Case Modeling
Lecture # 3
Use Case Modeling
What is a Use Case?
Narrative descriptions of domain processes in a
system
2
To describe functional System Specifications
3
The Scope of Use Cases
Analysis Design Test
and
Implementation
Use cases make up the glue
Capture Implement Verify that
use cases use cases use cases
are satisfied
Use Case
Implements
Designs Verifies
Programmer Tester
Architect
Case Study – The NextGen POS System
Computerized application used to record sales and
handle payments
Used in retail store
It includes hardware and software components
It also interfaces to other applications, such as a third-
party tax calculator and inventory control
Multiple and varied clients-side terminals and
interfaces
Commercial POS (a product)
5
Use Case, Actor, and Scenario
Actors
Something with behavior such as person, computer system, or
organization
Scenario
It is a specific sequence of actions and interactions between actors
and the system
It is also called use case instance
It is one particular story of using a system
Example: scenario of successfully purchasing items with cash or
scenario of failing to purchase items because of credit payment
denial
Use case then is a collection of success and failure scenarios
Use cases are requirements, primarily functional
6
Use Case, Actor, and Scenario
A UC is a dialogue between an actor and a system that
accomplishes a task
The dialogue is presented as a sequence of steps
A complete sequence of steps is a use case scenario
A scenario (UC instance) forms a complete path through
the UC
A UC can contain multiple scenarios/paths
UCs are not object-oriented artifacts! They feed into
other OO models
7
Kinds of Actors
• Primary actor
– has user goals fulfilled through using services of the system
– why identify? To find user goals, which drive use cases
• Supporting actor
– provides a service (for example, information) to the system
– why identify? To clarify external interfaces and protocols
• Offstage actor
– has an interest in the behavior of the use case
– why identify? To ensure that all necessary interests are identified
and satisfied
8
Guidelines: How to Find Use Cases?
Four Steps
1. Choose the system boundary
2. Find primary actors
3. Identify goals for each primary actor
4. Define use cases that satisfy user goals
i. Draw Use Case Diagram
9
1. Choose the System Boundary
Checkout Service
Sales Tax
Agency
POS System
Goal: Collect
taxes on sales Sales Activity
System Cashier
Customer
10
2 and 3. Primary Actors and their Goals
Brainstorm (pooling of spontaneous ideas about a
problem) the primary actors first
Questions to help identify actors and goals
Who starts and stops the system?
Who does user and security management?
Who does system administration?
Is “Time” an actor because the system does something in
response to a time event?
Are there any external software system that call upon the
services of the system?
Organize the actors and goals in an Actor Goal List
11
Actor Goal List
12
4. Define Use Cases that Satisfy User Goals
(i. Use Case Diagram)
system boundary NextGen POS communication
«actor»
Cash In Accounting
System
Manager
«actor»
«actor» Analyze Activity
HR System
Sales Activity
System
Manage Security
NextGen
«actor»
Process Sale Payment
Authorization
Service
Cashier
...
15
4. Define Use Cases that Satisfy User Goals
(ii. Writing Use Case Text)
Guideline: Black Box Use Cases
Black-Box Style:
Focus on what, not how
Defer implementation details
Avoid reference to specific technologies
16
4. Define Use Cases that Satisfy User Goals
(ii. Writing Use Case Text)
Use Case Formats
Brief, Casual, and Fully Dressed
Brief Format
17
4. Define Use Cases that Satisfy User Goals
(ii. Writing Use Case Text)
Causal Format
18
4. Define Use Cases that Satisfy User Goals
(ii. Writing Use Case Text) Fully Dressed Format
Use Case Sections Comments
Use case name Start with a verb
Scope The system under design
Level “User goal” or “Sub function”
Primary Actor Calls on system to deliver its services
Stakeholders and interests Who cares about the system and what do
they want
Preconditions What must be true on start
Success Guarantee What must be true on successful completion
Main Success Scenario Unconditional happy path scenario of
success
Extensions Alternate scenario of success or failure
Special Requirements Related NFRs
Technology and Data variation list Varying I/O methods
Frequency of occurrence Influences investigation, testing
19
Miscellaneous Open issues
Fully dressed Use Case
(e.g., Process Sale)
Use case UC1: Process Sale
Scope: Point of Sale
Level: User Goal
Primary Actor: Cashier
Stakeholders and Interests:
-Cashier: Wants accurate and fast entry, no payment errors, …
-Salesperson: Wants sales commissions updated.
Preconditions: Cashier is identified and authenticated.
Success Guarantee (Postconditions):
-Sale is saved. Tax correctly calculated.
Main success scenario (or basic flow): [on next slide]
Extensions (or alternative flows): [on next slide]
Special requirements: Touch screen UI, …
Technology and Data Variations List:
-Identifier entered by bar code scanner,…
Open issues: What are the tax law variations? …
UC1: Process Sale
Main success scenario (or basic flow):
The Customer arrives at a POS checkout with items to purchase.
The cashier records the identifier for each item. If there is more than one
of the same item, the Cashier can enter the quantity as well.
The system determines the item price and adds the item information to
the running sales transaction. The description and the price of the current
item are presented.
On completion of item entry, the Cashier indicates to the POS system
that item entry is complete.
The System calculates and presents the sale total.
The Cashier tells the customer the total.
The Customer gives a cash payment (“cash tendered”) possibly greater
than the sale total.
Extensions (or alternative flows):
If invalid identifier entered. Indicate error.
If customer didn’t have enough cash, cancel sales transaction.
Terminology: Concrete, Abstract, Base, and
Addition Use Cases
Concrete use case
is initiated by an actor
is an EBP use case
e.g., Process Sale
Abstract use case
is never instantiated by an actor
is a sub-function use case (part of another use case)
e.g., Handle Credit Payment
Base use case
that includes another use case, or that is extended or specialized by another use
case
e.g., Process Sale with respect to the included Handle Credit Payment
Addition use case
that is an inclusion, extension, or specialization
Handle Credit Payment in the include relationship to Process Sale
Addition use cases are usually abstract
Base use cases are usually concrete
Use Case Associations
Use case association = relationship between use cases
Important types:
Include
A use case uses another use case (functional decomposition and
reuse of existing functionality)
Extends
A use case extends another use case
Generalization
A use case has different specializations
≪include≫: Functional Decomposition
Problem:
A function in the original problem statement is too complex to be
solvable immediately
Solution:
Describe the function as the aggregation of a set of simpler functions.
The associated use case is decomposed into smaller use cases
CreateDocument
≪include≫
≪include≫
≪include≫
≪include≫
OpenIncident
ViewMap
Base Use ≪include≫
Case Supplier
AllocateResources Use Case
Example: Include Relationship
UC1: Process Sale
…
Main Success Scenario:
1. Customer arrives at a POS checkout with goods and/or services
to purchase
.…
7. Customer pays and System handles payment.
…
Extensions:
7b. Paying by credit: Include Handle Credit Payment.
7c. Paying by check: Include Handle Check Payment.
…
Example: Include Relationship cont…
UC12: Handle Credit Payment
…
Level: Sub-function
Main Success Scenario:
1. Customer enters their credit account information.
2. System sends payment authorization request to an external Payment
Authorization Service System, and requests payment approval.
3. System receives payment approval and signals approval to Cashier.
4. …
Extensions:
2a. System detects failure to collaborate with external system:
1. System signals error to Cashier.
2. Cashier asks Customer for alternate payment.
…
When to Use Include Relationship?
Use include when you are repeating yourself in
Base Use
Case B
Help
FieldOfficer
A ≪extend≫
ReportEmergency
≪extend≫ Association for Use Cases
The idea is to create an extending or addition use
CheckPassword
Parent ValidateUser
Child
Case
CheckFingerprint Use Case
Use-Case Experts advise to Keep Things Simple
and Prefer the include Relationship
NextGen POS
Process Sale
Cashier
«include» «include» «actor»
Accounting
«include» System
Handle Returns
Manage Users
...
35
Recommended Readings
Section 3.3, Chapter # 3: Case Studies from Applying UML and
Patterns: An Introduction to Object-Oriented Analysis and Design and
Iterative Development by Craig Larman, 3rd Edition
Chapter # 6: Use Cases from Applying UML and Patterns: An
Introduction to Object-Oriented Analysis and Design and Iterative
Development by Craig Larman, 3rd Edition
Chapter # 7: Other Requirements from Applying UML and Patterns: An
Introduction to Object-Oriented Analysis and Design and Iterative
Development by Craig Larman, 3rd Edition
Chapter # 30: Relating Use Cases from Applying UML and Patterns:
An Introduction to Object-Oriented Analysis and Design and Iterative
Development by Craig Larman, 3rd Edition
36