Details about Use Cases This section has been adapted from Dr.

advertisement
Details about Use Cases
This section has been adapted from Dr.
Scott Fleming of U. Memphis
What are “fully dressed” use cases?
• All steps and variations
written in detail
• Structured template
– Tend toward the formal
– However, rough
sketching can be useful
http://flic.kr/p/a6qunq
“Fully dressed” UC template
•
•
•
•
•
UC name
Scope
Level
Primary actor
Stakeholders and
interests
• Preconditions
• Success guarantees
• Main success scenario
• Extensions (or
alternative flows)
• Special requirements
• Technology and data
variations list
• Frequency of
occurrence
• Miscellaneous
Use Cases are a Bundle
• Each use case is a bundle of scenarios
• Usually include a “main success scenario” and
“exception scenarios”
Use Case Name
• Start with a verb
• Examples:
– Read Article
– Write Article
– Moderate Comment
Scope
• Will always be the software system under
development for us
• Example:
– Online Magazine Content Management System
• There also business use cases, but we don’t
care about them in this class
Level
Two levels that we care about:
• User-goal level: describes scenarios that fulfill the
goals of the primary actor
– Most common
• Subfunction level: describes substeps to support a
user goal
– Used to factor out common text from other use cases
– Good for handling common use cases like “Log in”
Primary actor
• Principal actor that calls upon system services
to fulfill a goal
– Usually human, but not always
Stakeholders and interests list
• “The [system] operates a contract between
stakeholders, with the use cases detailing the
behavioral parts of that contract… The use case, as the
contract of behavior, captures all and only the
behaviors related to satisfying the stakeholders’
interests” –Cockburn (2001)
• Example stakeholders and interests:
– Subscriber: Wants interesting and amusing articles
because the subscriber wants to get money’s worth; wants
to be involved in a community of like-minded users to
discuss topics and provide feedback to the magazine
– Editor: Wants high-quality written articles because lowquality articles reduce reader confidence and satisfaction
Stakeholders and interests list
• “The [system] operates a contract between
stakeholders, with the use cases detailing the
behavioral parts of that contract… The use case, as the
contract of behavior, captures all and only the
behaviors related to satisfying the stakeholders’
interests” –Cockburn (2001)
• Example stakeholders and interests:
– Subscriber: Wants interesting and amusing articles
because the subscriber wants to get money’s worth; wants
to be involved in a community of like-minded users to
discuss topics and provide feedback to the magazine
– Editor: Wants high-quality written articles because lowquality articles reduce reader confidence and satisfaction
Contains a Why description!
Preconditions
• Things that must always be true be the
scenario begins
– May imply completion of another UC’s scenario
• Examples:
– User has logged in
– Comment exists in moderation queue
• Skip uninteresting or obvious preconditions
– Anti-example: Editor has editing experience
– Anti-example: Subscriber can use web site
Success guarantees (postconditions)
• Things that must be true after the success
scenario or some alternative path
– Should meet the needs of all stakeholders
• Example:
– User has access to subscriber-only content
– Comment appears in article’s comment thread
– Edits to article are saved
Main success scenario
• Sequence of steps in a scenario of a successful
typical use of the system
• Three types of steps:
– Interaction between actors
– Validation (usually by system)
– State change of system (e.g., recording or modifying
something)
– (Additionally, step 1 may indicate a trigger event)
• Most actor actions should have a system
response
• Defer conditionals to Extensions section
• Idiom: capitalize actors names
Main Success Scenario 1:
Post Comment on Article
1. Subscriber access article
2. System presents article to subscriber, with comments
thread
3. Subscriber presses “Post comment”
4. System confirms that subscriber is permitted to post
comments
5. System presents text editor
6. Subscriber enters comment text
7. Subscriber submits comment
8. System records subscriber name, date of comment,
comment text, and article that was commented on
9. System posts comment at end of comment thread
Extensions (or alternative flows)
• All other scenarios and branches
– May end in success or failure
• Example:
– 1a. Used filtered language [words in the comment text on filtered list]
6.
7.
8.
Subscriber writes word on filtered word list
???
System shows the text editor, the error message, “Please do not use these
words in your post!”, and the words in the editor highlighted
– 1b. Subscriber is banned from posting comments [subscriber is on a
“banned from posting” list]
3.
4.
5.
Subscriber presses “Post comment”
System identifies that the subscriber is not permitted to post comments
System shows error message, “You are not allowed to post comments.”
– Guideline: write conditions as something that can be detected by
system or actor
Extensions (or alternative flows)
• All other scenarios and branches
– May end in success or failure
• Example:
– 1a. Used filtered language [words in the comment text on filtered list]
6.
7.
8.
Subscriber writes word on filtered word list
???
System shows the text editor, the error message, “Please do not use these
words in your post!”, and the words in the editor highlighted
– 1b. Subscriber is banned from posting comments [subscriber is on a
“banned from posting” list]
3.
4.
5.
Subscriber presses “Post comment”
System identifies that the subscriber is not permitted to post comments
System shows error message, “You are not allowed to post comments.”
– Guideline: write conditions as something that can be detected by
system or actor
Numbering starts at the point
from the main success scenario
Contains the condition
Extensions (cont’d)
• At end, the extension merges back with the main
success scenario unless the extension indicates
otherwise
• Complex extensions might be better expressed as
a separate UC
• Example: a condition that is possible during any
step of the main scenario:
– *a. System crashes…
• Example: branching to another use case:
– 2c. Author performs Edit Article in response to editor
feedback
Special requirements
• Non-functional requirements relevant to the
UC
– Ex: Section 508 (web accessibility), HIPAA (health
information privacy), etc
• Examples:
– Every image must have associated alternative text
for screen readers
– Identifiable information of patients cannot be
disclosed to non-employees
Technology and data variations list
• Constraints on how to build the system
– Typically imposed by the customer
• Examples (reference relevant steps):
– 4a. System must be compatible with Internet
Explorer 8, Chrome 22, Safari 4, and Firefox 17
– 5a. System will present its mobile user interface
when accessed using a mobile device with a four
inch screen or smaller
How could creating “fully dressed”
use cases be useful?
(Why write them?)
How could creating “fully dressed”
use cases be useful?
•
•
•
•
•
Aid for thinking through what to build
Help with detailed planning
Reveal other use cases
? Documenting requirements ?
? Communicating with customer ?
Project-specific costs/benefits
very important to consider!
Requirements derived from a Use Case
FR 1: Subscriber posts comment
FR 1.1: Subscriber can post a comment associated with an article
FR 1.2: Every comment appears at the bottom of the article text
FR 1.3: Comment stores the comment text, the subscriber name, the
comment date of posting, and the associated article identifier
FR 1.4: Comments containing offensive words have posting restrictions
FR 1.4.1: Comments posted by subscribers may not contain offensive
words
FR 1.4.2: Comments posted by moderators may contain Offensive
Words
FR 1.4.3: Offensive words appear on the “offensive words list”
This might not be necessary depending on the project.
Some developers are good at identifying necessary
information from the use case directly.
Consider this motivating example
At requirements workshop, an editor
says she needs to “log in to the system”
Is he making assumptions about the solution?
How might that limit you, as the designer?
How can you prevent customers
from accidentally imposing
unnecessary requirements?
Guideline: Write in essential style
• Express narrative at level of
– user’s intentions and
– system’s responsibilities
• Avoid UI details!!
What is wrong with this example?
1. Moderator enters ID and password in dialog
box.
2. System authenticates Moderator
3. System displays the “edit users” window
What is wrong with this example?
1. Moderator enters ID and password in dialog
box.
2. System authenticates Moderator
3. System displays the “edit users” window
• Limits possible designs by specifying UI
Here’s an essential-style example
1. Moderator identifies self.
2. System authenticates Moderator’s identity.
• This version leaves open novel solutions such
as hardware authenticators that the other
system could not accomodate
Here’s another motivating example
Consider a UC step that says
“The system generates a SQL INSERT statement for
the sale…”
What assumptions does the UC make?
How might those assumptions limit you?
How can you prevent customers
from accidentally imposing
these sorts of unnecessary
requirements?
Guideline: Use black-box style
• Do not describe internal workings of system
• Say what the system does, not how it does it
• Think of system in terms of its responsibilities
How might you word this step using
black box?
• The system generates a SQL INSERT statement
for the sale…
How might you word this step using
black box?
• The system generates a SQL INSERT statement
for the sale…
• Like this: The system records the sale.
Consider this motivating quote
“the software industry is littered with failed projects
that did not deliver what people really needed”
— Larman
How can we make sure we deliver what our
customers really need?
Guideline: Actor and actor-goal
perspective
• Write requirements focusing on the users
(actors) of a system, asking about their goals
and typical situations
– Look for different types of users
• Focus on understanding what the actor
considers a valuable result
We know that the customers have difficulty effectively
communicating requirements
How can we discover requirements that
the customer might not think to tell us about?
Guideline for finding requirements
• Ask probing questions that focus on:
– The primary actors and their goals
– The system boundary
• Prototyping and other activities
Such probing might produce
a helpful diagram like this
Bicycle
stations
Phone
customer
Phone
system
The System
Phone
support
Mobile/web
customer
Service
tech
Download