L04 Use Case Model (Ch06)
L04 Use Case Model (Ch06)
& Design
面向对象的分析与设计
修佳鹏
[email protected]
计算机学院(国家示范性软件学院)
北京邮电大学
Part 2: Inception
2
Chapter 6 Use Cases
• Objectives:
3
Sample UP Artifact Relationships
Domain Model
Sale Sales
Business 1 1 ..
LineItem
* ...
Modeling
date
...
objects , attributes ,
associations ...
scope , goals , Vision
Use - Case Model
quantity 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
enterItem
Post - conditions :
( id , quantity ) non - functional reqs
-...
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?
5
Use-Case Model
6
Applying UML: Use Case Diagrams
system NextGen POS communication
boundary
Process Sale
«actor »
Case
Cash In Accounting
Syste Diagram
Manager m
«actor »
«a ctor » Analyze Activity
HR System
Sales Activity
Syste
m
Manage Security use case text
System
Administrator Manage
ManageUser
Users
use case
. .Role
Manage .
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
Syste
Manager m
«actor »
«a ctor » Analyze Activity
HR System
Sales Activity
Syste
m
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 Activity
sales 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 customer
product
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.
3
3
A fully-dressed use case example
Extensions (or Alternative Flow):
*a. At any time, Manager requests and override operations:
1. System enters Manager-authorized modes
2. Manager or Cashier performs one Manager-mode operation, e.g.
cash balance change, resume a suspended sale on …
3. System reverts to Cashier-authorized mode.
*b. …
1a. Customer or Manager indicate to resume a suspended sale.
4. Cashier performs resume operations, and enters the ID to retrieve
the sale
5. System displays the state of the resumed sale, with subtotal.
…
4 a. Customer tells Cashier they have a tax-exempt status (e.g., seniors)
1. Cashier verifies, and then enters tax-exempt status code.
2. System records status (which it will used during tax calculation)
3a. Invalid item ID (not found in system);
1. … 3
4
Details
• 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:
3. Administrator enters ID and password in dialog box (see Picture 3).
4. System authenticate Administrator.
5. 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
• 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
55
Experiment 1
• 分析你们小组目标系统的需求分析:
• 1 、完善系统用例图;
• 2 、针对每个用例撰写用例说明,形成完整的 Use-Case Model ;
• 4 、 完 善 其 他 需 求 分 析 制 品 ( Vision 、 Supplementary Specification 、
Glossary 、 Business Rules )
56