CSE870: Adv.
Software Engineering
RE
MDE
SE
Use Cases and Scenarios
CSE870: Advanced Software Engineering: UML-- Use Cases 1
RE
MDE We Will Cover
SE
• What is a use-case
– Use-case versus user interaction
• Use-Case diagrams
– The constructs in the use-case diagrams
• Capturing the use-case
– High-level use-case
– Extended use-case
– Difference between use case and scenario
CSE870: Advanced Software Engineering: UML-- Use Cases 2
CSE870: Advanced Software Engineering
(UML) 1
CSE870: Adv. Software Engineering
RE
MDE What is a Use-Case
SE
• A use-case captures some user visible function
• This may be a large or small function
– Depends on the level of detail in your modeling effort
• A use-case achieves a discrete goal for the user
• Examples
– Format a document
– Request an elevator
• How are the use cases found (captured or
elicited)?
CSE870: Advanced Software Engineering: UML-- Use Cases 3
RE User Goals versus
MDE
SE User Interactions
• Consider the following when formatting a document
• Define a style
• Change a style
• Copy a style from one document to the next
– versus
• Format a document
• Ensure consistent formatting of two documents
• The latter is a user goal
– Something the user wants to achieve
• The former are user interactions
– Things the user does to the system to achieve the goal
CSE870: Advanced Software Engineering: UML-- Use Cases 4
CSE870: Advanced Software Engineering
(UML) 2
CSE870: Adv. Software Engineering
RE
MDE Goals and Interactions
SE
• There is a place for both goals and interactions
• Understand what the system shall do
– Capture the user goals
• Understand how the user will achieve the goals
– Capture user interactions
– Sequences of user interactions
• Thus, start with the user goals and then refine
the user goals into several (many) user
interactions
CSE870: Advanced Software Engineering: UML-- Use Cases 5
RE
MDE Point of Sale Terminal (POST)
SE
• Computerized system to record sales and
handle payments
• Typically used in a retail store
• Includes HW components, such as computer
and bar code scanner
• Software to run the system
• Goals of system:
– Increase checkout automation
– fast and accurate sales analysis
– automatic inventory control
CSE870: Advanced Software Engineering: UML-- Use Cases 6
CSE870: Advanced Software Engineering
(UML) 3
CSE870: Adv. Software Engineering
RE
MDE Use-Case Diagrams (POST)
SE
POST: Point of Sale Terminal
Use Case
POST
System Boundary
Buy Item
Log In
Cashier Customer
Refund a Purchased Item
Adapted from Larman “Applying UML and Patterns”
CSE870: Advanced Software Engineering: UML-- Use Cases 7
RE
MDE Another Example
SE
Financial Trading System
Set Limits
Update Accounts Accounting System
Trading Manager
Analyze Risk
«includes»
Valuation
«includes»
Price Deal
Trader
Capture Deal
«extends» Salesperson
Adapted from Fowler “UML Distilled”
Limit Exceeded
CSE870: Advanced Software Engineering: UML-- Use Cases 8
CSE870: Advanced Software Engineering
(UML) 4
CSE870: Adv. Software Engineering
RE
SE
MDE Includes and Extends
• Includes/Uses • Extends
– You have a piece of – A use-case is similar to
behavior that is similar another one but does a little bit
across many use cases more
– Break this out as a separate – Put the normal behavior in one
use-case and let the other use-case and the exceptional
ones “include” it behavior somewhere else
– Examples include • Capture the normal behavior
• Try to figure out what can go
• Valuation
wrong in each step
• Validate user interaction
• Capture the exceptional cases
• Sanity check on sensor in separate use-cases
inputs
– Makes it much easier to
• Check for proper
understand
authorization
CSE870: Advanced Software Engineering: UML-- Use Cases 9
RE
MDE Setting the System Boundary
SE
• The system boundary will affect your
actors and use-cases
POST
Buy Item
Log In
Cashier Customer
Refund a Purchased Item
Adapted from Larman “Applying UML and Patterns”
CSE870: Advanced Software Engineering: UML-- Use Cases 12
CSE870: Advanced Software Engineering
(UML) 5
CSE870: Adv. Software Engineering
RE
MDE A Different Boundary
SE
• Let us view the whole store as our system
Store
Buy Item
Refund a Purchased Item
Customer
Adapted from Larman “Applying UML and Patterns”
CSE870: Advanced Software Engineering: UML-- Use Cases 13
RE
MDE Partial POST
SE
POST
Buy Item
Log In
Cashier Customer
Refund a Purchased Item
Start Up
Manager
Manage Users
System Administrator
And a Lot More
Adapted from Larman “Applying UML and Patterns”
CSE870: Advanced Software Engineering: UML-- Use Cases 14
CSE870: Advanced Software Engineering
(UML) 6
CSE870: Adv. Software Engineering
RE
MDE POST Use-Case
SE
Use case: Buy Item
Actors: Customer (initiator), Cashier
Type: Primary
Description: The Customer arrives at the
checkout with items to purchase.
The Cashier records the purchase
items and collects a payment.
On completion the Customer
leaves with the items
CSE870: Advanced Software Engineering: UML-- Use Cases 15
RE
MDE POST Expanded Use-Case
SE
Use case: Buy Item
Actors: Customer (initiator), Cashier
Type: Primary and essential
Description: The Customer arrives at the checkout with items
to purchase. The Cashier records the purchase
items and collects a payment. On completion the
Customer leaves with the items.
Cross Ref.: Requirements XX, YY, and ZZ
Use-Cases: Cashier must have completed the Log In use-case
CSE870: Advanced Software Engineering: UML-- Use Cases 16
CSE870: Advanced Software Engineering
(UML) 7
CSE870: Adv. Software Engineering
RE
MDE The Home Heating System
SE
Water Valve
Water Pump
Hot Water Home
Controller
Burner
Fuel Valve
90
80 Off
70
On
Fuel 60
50
Control Panel
Temp Sensor
CSE870: Advanced Software Engineering: UML-- Use Cases 17
RE
MDE
SE Home Heating Use-Case Diagram
Home Heating
Power Up
Power Down
Home Owner
Change Temp.
CSE870: Advanced Software Engineering: UML-- Use Cases 18
CSE870: Advanced Software Engineering
(UML) 8
CSE870: Adv. Software Engineering
RE
MDE Home Heating Use-Cases
SE
Use case: Power Up
Actors: Home Owner (initiator)
Type: Primary and essential
Description: The Home Owner turns the power on. Each room
is temperature checked. If a room is below the
the desired temperature the valve for the room is
opened, the water pump started, the fuel valve
opened, and the burner ignited.
If the temperature in all rooms is above the desired
temperature, no actions are taken.
Cross Ref.: Requirements XX, YY, and ZZ
Use-Cases: None
CSE870: Advanced Software Engineering: UML-- Use Cases 19
RE
MDE Modified Home Heating
SE
Home Heating
Power Up Temp. High
«includes»
«includes»
Power Down Adjust Temp
«includes»
Home Owner
«includes»
Change Temp. Temp. Low
CSE870: Advanced Software Engineering: UML-- Use Cases 20
CSE870: Advanced Software Engineering
(UML) 9
CSE870: Adv. Software Engineering
RE
MDE HACS
SE
• Homework assignment and collection are an integral part of any
educational system. Today, this task is performed manually.
What we want the homework assignment distribution and
collection system (HACS for short) to do is to automate this
process.
• HACS will be used by the instructor to distribute the homework
assignments, review the students’ solutions, distribute
suggested solution, and distribute student grades on each
assignment.
• HACS shall also help the students by automatically distributing
the assignments to the students, provide a facility where the
students can submit their solutions, remind the students when
an assignment is almost due, remind the students when an
assignment is overdue.
CSE870: Advanced Software Engineering: UML-- Use Cases 21
RE
MDE In-class exercise
SE
Work in Pairs
• Create use case diagram
• Have an example of <<includes>>
relationship
• Bonus: have an example of
<<extends>> relationship
• Remember to include key elements of
UC diagram.
CSE870: Advanced Software Engineering: UML-- Use Cases 22
CSE870: Advanced Software Engineering
(UML) 10
CSE870: Adv. Software Engineering
RE
MDE HACS Use-Case Diagram
SE
HACS
Configure HACS Remind Student
Distribute Asignments Get Assignment
System Admin
Post Solutions Submit Assignment
Student
Distribute Grade
Get Solution
Instructor
Get Grade
CSE870: Advanced Software Engineering: UML-- Use Cases 23
RE
MDE HACS Use-Cases
SE
Use case: Distribute Assignments
Actors: Instructor (initiator)
Type: Primary and essential
Description: The Instructor completes an assignment and submits
it to the system. The instructor will also submit the
due date and the class the assignment is assigned for.
Cross Ref.: Requirements XX, YY, and ZZ
Use-Cases: Configure HACS must be done before any user
(Instructor or Student) can use HACS
CSE870: Advanced Software Engineering: UML-- Use Cases 24
CSE870: Advanced Software Engineering
(UML) 11
CSE870: Adv. Software Engineering
RE
MDE Alternate HACS
SE
HACS
Configure HACS
Distribute Asignments
System Admin
Post Solutions
Distribute Grade
Student
Instructor
Remind Student
Submit Assignment
CSE870: Advanced Software Engineering: UML-- Use Cases 25
RE
MDE When to use Use-Cases
SE
• In short, always!!!
• Requirements is the toughest part of software
development
– Use-Cases is a powerful tool to understand
• Who your users are (including interacting systems)
• What functions the system shall provide
• How these functions work at a high level
• Spend adequate time on requirements and in the
elaboration phase
CSE870: Advanced Software Engineering: UML-- Use Cases 27
CSE870: Advanced Software Engineering
(UML) 12