use cases chapter 7 appendix a. 2 what are use cases? note: users are most often persons, but on...
TRANSCRIPT
Use Cases
Chapter 7 Appendix A
2
What Are Use Cases?
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.
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.
3
Purpose of Use Cases 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
4
Use Cases as Input for Analysis
Use CaseDescriptions
DraftFunctional
Req’mts
DraftTest Cases
Draft AnalysisModels
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
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 5
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
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 6
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
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 7
8
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 inPost-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
9
Use Case Template – Example (cont’d)Main Success Scenario:
1. Purchaser selects to buy stocks over Web2. PAF gets name of web site to use (E*Trade, Schwab, etc.) from user3. PAF opens web connection to the site, retaining control4. Purchaser browses and buys stock from the site5. PAF gets responses from the web site and updates purchaser’s portfolio6. 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 connected3a1. PAF reports this to purchaser3a2. Purchaser either backs out of session or tries again
4a. Web site does not acknowledge purchase, but puts it on delay4a1. 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??
10
Practical Hint: Usage Narratives 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
11
Usage Narrative -- An Example 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.
12
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.
13
Usage Narrative – Some Questions
Where would the information in the usage narrative come from?
How would it be collected? How would it be validated?
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
FIGURE 7-29A template for writing use cases(Source: Writing Effective Use Casesby A. Cockburn, © 2001. Adapted bypermission of Pearson Education, Inc.,Upper Saddle River, NJ 07458.)
14Chapter 7 Appendix A
Note that not all elements need be present in every use case
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
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
15Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
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
16Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
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
17Chapter 7 Appendix A
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 18Chapter 7 Appendix A
Use case at very high level
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
Use case at detail level
Corresponds with Step 1 of High-level use case
19Chapter 7 Appendix A
20
From Narrative to Use Case
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.
21
Another Sample Rx System Use Case (high level):
Main Success Scenario1. Doctor enters Rx into system2. Doctor receives confirmation of Rx accuracy3. Nurse at nurse station receives label information4. Patient receives Rx5. Billing and Patient DBs are updatedExceptions:
1a. Doctor not authorized for this patient 1a1. Rx denied2a. System detects allergy conflict 2a1. Sends Rx back to doctor2b. System detects Rx interaction 2b1. Sends Rx back to doctor3a. Rx sent to wrong Nurses Station 3a1. Nurse sends Rx back to Pharmacy4a. Patient status changed 4a1. Nurse sends Rx back to Pharmacy5a. Patient record unavailable 5a.1 ??
22
Putting It Together # 1Recall 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 (web-based) 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.
23
Putting It Together # 1(cont’d)
1. Review the sample version of the Context DFD – provided on the next slide
2. Work with your team to create a use case from the sample usage narrative given below.
3. Add one or more additional exceptions from the one(s) identified in the given usage narrative.
Here’s your task:
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 the problem is not corrected, the transaction will be canceled.
ProposedSystem
SeminarAttendee
registration_req_w_cc
cancellation_req
catalog_search_req
confirmation_of_seat
confirmation_of_cc_pmt
confirmation_of_cancellation
registration_declineseminar_reminder
Email Sys
Seminar Mgrreport
seminar_reminder
CorporateFinancial System
payment_info
credit
action
Seminar Data Store
Attendee Data Store
search_results
ContextDFD
attendee_information
seminar_information
report_req