L04 Use Case Model (Ch06)
L04 Use Case Model (Ch06)
& Design
面向对象的分析与设计
Part 2: Inception
2
Chapter 6 Use Cases
• Objectives:
3
Sample UP Artifact Relationships
Domain Model
Sale Sales
Business 1 1 .. * ...
LineItem
Modeling date ...
quantity
...
objects , attributes ,
associations
scope , goals , Vision
Use - Case Model
actors , features
Process Sale
Process
use
Sale 1 . Customer
case
Cashier
arrives ... 2 .
names
Cashier
makes new
sale .
terms , attributes ,
3 . ... Glossary
validation
Requirements
Use Case Diagram Use Case Text
system
events
: System
Operation : : Cashier
make Supplementary
enterItem (… )
system NewSale () Specification
operations
Post - conditions :
enterItem
- . .. non - functional reqs ,
( id , quantity )
quality attributes
Operation Contracts System Sequence Diagrams
requirements
Design Model
: Register : ProductCatalog : Sale
enterItem
Design (itemID , quantity )
• Use case are text stories, they are simple and familiar.
• Makes it easier for customers to contribute to requirement definition and
review, that lowers the risk of missing the mark.
• More user centric (compared with traditional feature list)
– Who is using the system?
– What are their goals?
– What are their typical scenarios of use?
• Use case is a good way for domain experts or requirement donors to
write use cases by themselves, is the central to discover and define the
functional requirements.
• Able to scale both up and down in terms of sophistication and formality.
5
Use-Case Model
6
Applying UML: Use Case Diagrams
system NextGen POS communication
boundary
Process Sale
Use Case
Handle Returns «actor »
Tax
actor Cashier Calculator
«actor »
Diagram
Cash In Accounting
System
Manager
«actor »
«a ctor » Analyze Activity
HR System
Sales Activity
System
7
Notation Guidelines
NextGen
supporting actors
on the right
primary actors
on the left
13
8
Some Use Cases Examples
9
Some Use Cases Examples
10
Some Use Cases Examples
11
Some Use Cases Examples
12
Some Use Cases Examples
13
What are Actors, Scenarios, and Use Cases
• Actor
– something with a behavior; such as a person, computer system,
machines or organization, System under Discussion (SuD)
itself when it calls upon the services of other systems.
• Scenario——Use Case Instance
– A specific sequence of actions and interactions between actor
(s) and the system (one story; success or failure)
• Use Case
– A collection of related success and failure scenarios
describing the actors attempts to support a goal
14
Three Kinds of Actors
15
Three Kinds of Actors
system NextGen POS communication
boundary
Process Sale
Customer Payment
Authorization
Service
Handle Returns «actor »
Tax
Cashier Calculator
Supporting actor
Primary actor «actor »
Cash In Accounting
System
Manager
«actor »
«a ctor » Analyze Activity
HR System
Sales Activity
System
Manage Security
System
Administrator Manage
ManageUser
Users
use case
. .Role
Manage .
16
How to Find Use Cases
17
How to Find Use Cases
Checkout Service
Sales Tax
Agency
POS System
Goal: Collect
taxes on sales Sales Activity
System Cashier
Customer
19
At Which Level to Write a Use Case
project goal
Strategic Goals
“white”
advertise order invoice
Subfunctions “indigo”
identify register user identify identify
promotion product customer
Actor Goal
Cashier Process sales
Process rentals
Handle returns
…
Manager Start up
Shut down
21
Other Ways to Find Actors and Goals
22
Questions to Help Find Actors and Goals
23
Questions to Help Find Actors and Goals
24
What Tests Can Help Find Useful Use Cases?
25
Example: Applying the Tests
• Handle Returns
– OK with the boss. Seems like an EBP. Size is good
• Log In
– Boss not happy if this is all you do all day
26
Use Cases vs. Feature Lists
27
Use Case Text
28
A Use Case Example (Brief format)
29
Example (Casual format)
Handle Returns
Alternate Scenarios:
Stakeholders and Interests Who cares about this use case, and what do they want?
Preconditions What must be true on start, and worth telling the reader
Success Guarantee What must be true on successful completion, and worth telling
the reader?
Technology and Data Variations Varying I/O methods and data formats.
List
Frequency of Occurrence Influences investigation,testing,and timing of implementaton.
• Scope
– System use case vs. business use case
• Level
– User-goal level, Elementary business process (EBP)
– Subfunctions-level, Ex. Pay by Credit
• Stakeholders and Interests
– Important: defines what the use case covers, “that which satisfies the
stakeholders’ interests”
• Preconditions
– What must always be true before beginning a scenario in the use case
(e.g., “user is already logged in”)
35
Details
37
Other Formats of Use Case
There isn't one best format. Sections may be added and removed.
The key thing is to write the details of the main success scenario and its extensions.
38
Guideline: Write in an Essential UI-Free Style
• Contrasting Examples
Essential Style:
1. Administrator identifies self.
2. System authenticates identity.
3. …
Concrete Style:
1. Administrator enters ID and password in dialog box (see Picture 3).
2. System authenticate Administrator.
3. System displays the “edit users” window (see Picture 4).
4. …
39
Guideline: Write terse Use Cases
40
Guideline: Write Black-Box Use Cases
41
Example:Monopoly Game
14
42
Evolve Use Cases and Other Specification
Across the Iterations
16
43
UP Artifacts and Timing
s: start; r: refine
44
44
Relationships of Use Case
45
Guideline : Avoid Agonizing Over Use Case
Relationships
46
The Include Relationship
47
The include Relationship Example
NextGen POS
Process Sale
Cashier
«include» «include» «actor»
Accounting
«include» System
Manage Users
...
50
Terminology : Concrete , Abstract , Base ,
and Addition Use Cases
51
The Extend Relationship
• Suppose a use case's text should not be modified (at least not
significantly) for some reason, or the use case has been
baselined as a stable artifact and can't be touched.
• Continually modifying the use case with myriad new
extensions and conditional steps is a maintenance headache.
How to append to the use case without modifying its original
text?
• The extend relationship provides an answer. The idea is to
create an extending or addition use case and within it
describe where and under what condition it extends the
behavior of some base use case.
52
The extend Relationship
UC1: Process Sale (the base use case)
…
Extension Points: VIP Customer, step 1. Payment, step 7
Main Success Scenario:
1. Customer arrives at a POS checkout with goods and/or services to
purchase
…
7. Customer pays and System handles payment
…
UC15: Handle Gift Certificate Payment (the extending use case)
…
Trigger: Customer wants to pay with gift certificate
Extension Points: Payment in Process Sale
Level: Subfuction
Main Success Scenario:
1. Customer gives gift certificate to Cashier
2. Cashier enters gift certificate ID
… 53
The extend relationship
Process Sale
Extension Points:
Payment UML notation:
VIP Customer 1.The extending use case
points to the base use case.
«extend»
Payment, if Customer 2.The condition and
presents a gift certificate extension point can be
shown on the line.
Handle Gift Certificate
Payment
54
Homework
• 从你们组的用例模型中选择一个你认为最重要的用例,以
Fully Dressed形式编写该用例的用例说明:
55
Experiment 1
• 分析你们小组目标系统的需求分析:
• 1、完善系统用例图;
• 2、针对每个用例撰写用例说明,形成完整的Use-Case Model;
• 4、完善其他需求分析制品( Vision 、Supplementary
Specification 、 Glossary 、 Business Rules )
56