Transcript Use case

Use Cases
Chapter 7 Appendix A
What Are Use Cases?
A use case describes a scenario of interactions
between a system and a user that results in the user
accomplishing some meaningful task or goal.
Note: Users are most often persons, but on occasion, they could
be another program, hardware – any entity that interacts with the
system to achieve some goal.
2
Purpose of Use Cases



3
To describe the tasks users will need to perform with
the system
Use cases can capture functional requirements from
the user’s perspective
Use cases frequently expose user requirements that
might otherwise have been forgotten or glossed over
Use Cases as Input for Analysis
Draft
Functional
Req’mts
Use Case
Descriptions
Draft
Test Cases
Draft
Analysis
Models
4
Use Cases
Use case is a depiction of a system’s
behavior or functionality under various
conditions as the system responds to
requests from users.
 Actor is an external entity that interacts
with the system.

Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
5
Use Cases (Cont.)



Most actors represent user roles, but actors can
also be external systems.
An actor is a role, not a specific user; one user
may play many roles, and an actor may
represent many users.
A use case model consists of actors and use
cases.
Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
6
Written Use Cases
Document containing detailed
specifications for a use case
 Contents can be written as simple text or
in a specified format
 Step-by-step description of what must
occur in a successful use case

Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
7
Use Case Template – Example
Use Case 1: Buy Stocks over the Web
(adapted from Alistair Cockburn, Writing Effective Use Cases, 2001)
Primary Actor: Purchaser, employing Personal Advisor Financial (PAF) System
Pre-conditions: User already has PAF open and is logged in
Post-conditions:
Minimal Guarantee : Sufficient information will be logged for PAF
to detect errors and ask user for additional information if needed
Success Guarantee : Remote Web site acknowledges purchase and
the logs and user’s portfolio are updated
cont’d 
8
Use Case Template – Example
(cont’d)
Main Success Scenario:
1. Purchaser selects to buy stocks over Web
2. PAF gets name of web site to use (E*Trade, Schwab, etc.) from user
3. PAF opens web connection to the site, retaining control
4. Purchaser browses and buys stock from the site
5. PAF gets responses from the web site and updates purchaser’s portfolio
6. PAF shows users the new portfolio
Exceptions:
2a. Purchaser wants a web site that PAF does not support
2a1. System gets new suggestion from purchaser, with option to
cancel session
3a. Web site cannot be connected
3a1. PAF reports this to purchaser
3a2. Purchaser either backs out of session or tries again
4a. Web site does not acknowledge purchase, but puts it on delay
4a1. PAF logs delay, sets timer to ask purchaser about the outcome
5a. Connection to web site is broken during transmission of response.
5a1. PAF notifies purchaser of interruption – then what??
9
Practical Hint: Usage Narratives



10
Sometimes it is useful to write a usage narrative
before developing a use case proper
These should be a relatively brief overview – not
intended to be a finalized requirement
The usage narrative is used with customers to get
the essential information needed to abstract a more
general use case – a kind of use case preliminary
Usage Narrative -- An Example




11
Suppose you’ve been asked to work as an analyst
on a new system to track pharmacy functions in a
hospital.
You decide a good first step might be to construct a
usage narrative to begin the analysis process.
On the next slide is a sample of what such a
narrative might be.
We will shortly see how to construct a use case
from such a narrative.
Example Usage Narrative -- Hospital Pharmacy
The Hospital Pharmacy fills prescriptions for the hospital’s patients and distributes
these to the Nurse Station responsible for each patient. The prescription is written
by the doctor and sent to the pharmacy where the pharmacist reviews the
prescription, checks the patient drug file to determine the appropriateness, such as
allergies the patient may have or errors in the prescription (i.e. labor inducement
medication prescribed to a male patient). The pharmacist then fills the order if there
are no known patient allergies to the drug, and the drug does not interact with other
drugs the patient is taking.
If the pharmacist decides not to fill the order the doctor is contacted and advised of
the problem. The doctor then may decide to have the order filled anyway or the
doctor may write another prescription and resubmit it to the pharmacy.
Once the prescription is filled a label is generated with the patient information,
prescription information and medical information (instructions). The Patient ID and
new drug information are entered by the pharmacy into the Patient Drug File. The
patient ID number, drug name, amount dispensed and cost of the drug are entered
by the pharmacy into the on-line cost center system. The filled Rx is then sent to the
appropriate Nurse Station to be administered to the patient.
12
Usage Narrative – Some
Questions



13
Where would the information in the usage
narrative come from?
How would it be collected?
How would it be validated?
Note that not all
elements need be
present in every
use case
FIGURE 7-29
A template for writing use cases
(Source: Writing Effective Use Cases
by A. Cockburn, © 2001. Adapted by
permission of Pearson Education, Inc.,
Upper Saddle River, NJ 07458.)
Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
14
Sample Format for Written Use
Case

Title – descriptive name, matches name in
use case diagram

Primary actor – usually a user role

Stakeholders – any group or individual
with an interest in the function of the use
case
Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
15
Sample Format for Written Use
Case (Continued)

Precondition – conditions that must be
satisfied in order to execute the use case

Minimal guarantee – outputs that can be
expected if the service attempt failed

Success guarantee – outputs that can be
expected if the service succeeds
Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
16
Sample Format for Written Use
Case (Continued)

Trigger – an event or action that initiates
the use case

Main success scenario – description of
sequence of interactions between actor and
use case during the use case execution

Extensions – detailed description of how
errors are dealt with
Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
17
Use case at very high level
Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
18
Use case at detail
level
Corresponds with
Step 1 of Highlevel use case
Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
19
From Narrative to Use Case


20
Once the usage narrative is written and
validated, it can be used as the foundation for
a use case
Employing our use case template, the
pharmacy usage narrative might produce the
following use case.
Another Sample
Rx System Use Case (high level):
21
Main Success Scenario
1. Doctor enters Rx into system
2. Doctor receives confirmation of Rx accuracy
3. Nurse at nurse station receives label information
4. Patient receives Rx
5. Billing and Patient DBs are updated
Exceptions:
1a. Doctor not authorized for this patient
1a1. Rx denied
2a. System detects allergy conflict
2a1. Sends Rx back to doctor
2b. System detects Rx interaction
2b1. Sends Rx back to doctor
3a. Rx sent to wrong Nurses Station
3a1. Nurse sends Rx back to Pharmacy
4a. Patient status changed
4a1. Nurse sends Rx back to Pharmacy
5a. Patient record unavailable
5a.1 ??
Putting It Together # 1
Recall the following a prior lecture for a proposed new online system
to automate seminar registration for a company.
Here are the salient features of that proposed system:

Seminar registration is now handled by mail or by phone, based on seminar
brochures sent out in the mail. The customer wishes to implement an online (webbased) enrollment system.

A potential seminar enrollee should be able to go to the new web site, select a
specific seminar and then pay for and enroll in it if space is available.

Payment would be made by online credit card transaction. The payment
information and transaction approval is currently handled by the corporate financial
system.

The system should send an email reminder to each paid participant a week before
the seminar is scheduled for delivery.

The seminar manager requested an on-demand report showing the current status
of enrollment for all seminars being offered.
22
Putting It Together # 1(cont’d)
Here’s your task:
1.
2.
3.
Review the sample version of the Context DFD – provided on the next slide
Work with your team to create a use case from the sample usage narrative
given below.
Add one or more additional exceptions from the one(s) identified in the given
usage narrative.
Example Usage Narrative -- Seminar Registration
Pre-Conditions:
 User has an established account and has logged into that account. (See Use
Case # …)
 User has completed a catalog search and decided on a seminar. (See Use Case
# …)
The user will identify and submit the selected course for which they wish to register.
If the selected seminar is unavailable, the system will give the user the option of
selecting an alternate seminar. If the selected seminar is available, the system will
ask the user to confirm the transaction and submit a credit card for charging. If the
credit card is valid, it will be charged immediately and the registration will be
confirmed. If the card is not valid, the user will be asked to correct the problem. If
the23problem is not corrected, the transaction will be canceled.
ContextDFD
Attendee Data Store
seminar_reminder
Email Sys
seminar_reminder
registration_decline
attendee_information
confirmation_of_cancellation
catalog_search_req
Seminar
Attendee
registration_req_w_cc
payment_info
Proposed
System
credit
action
Corporate
Financial System
cancellation_req
confirmation_of_seat
Seminar Mgr
confirmation_of_cc_pmt
seminar_information
search_results
Seminar Data Store