User Story (US) vs. Use Cases (UC)
- US has shorter descriptions,
- US are more general (less detailed) than UC
- US focus on Who & Why, UC focus on User flow and their interaction with the systems (e.g. actor-initiated or system-initiated)
- US has no technical detail, while UC is technical
Definition: Use Case is a sequence of actions a system that yields an observable result of value to the particular actor
- From actors' perspective -- same group of people in the use case diagram
- Scenario: the sequence of actions that required in each use case
- Appropriate for situations (e.g. off-shore teams) in which implementation details are needed
- Complicated, time-consuming to produce, hard to maintian
Relationship with other artifacts
- 1:1:1 -- Event table activities --> Use Cases in UC Diagram --> Detailed Use Case Senarios
- Event table Source & Destination --> Actors in UC Diagram
Componenents
- <Use Case Name>
- <Summary> -- description of the use case
- <Actor> -- an external person or external system triggering the use case
- <Input Data> -- similar to inflow data in data flow diagram
- <Output Data> -- similar to outflow data in data flow diagram
- <Basic Flow> -- the "happy path" -- only one, error-free, executed 80% of the time -- good 1st MVP
- <Alt. Flow> -- the "exception path" -- all error cases, unpredicatable, executed 1 out of 10 times
- <Invariant> -- stay true throughout the use case
- <Pre-condition> -- the state of the system before the use case initiated
- <Post-condition> -- the state of the system after the use case initiated
- <Extention Points> -- includes and extends in the use case diagram
- <Business Rules>
Basic Flow
Always create the flow from a business perspective
Consider the business function you want to accomplish
Avoid implementation specific details
In the form of stimulus response: Actor --> System --> Actor --> System ...
Example
Alt. Flow
Supported & defined by business rules
Example 1
- Business rule: >= 21 yrs old to rent a car
- Happy path: I am >= 21 yrs old, I get a rental
- Alt. path: I am 20, get a sessage that I cannot get the rental
Example 2
Subflow
Definition: Sometimes a Use Case has several distinct cases
- Each case is distinct and separate from the others
- No hierarchical relationship between the cases
- Describe the Use Case with Subflows—one for each case
Example
4.
The
system
executes one and only one of the following subflows:
a.
If the clerk selected “Add a Product”, the Add a Product subflow is executed
b.
If the clerk selected “Change a Product”, the Change a Product subflow is executed
c.
If the clerk selected “Delete a Product”, the Delete a Product subflow is executed
![](https://img-blog.csdnimg.cn/a88b5f490861445782da765ca02dc6c6.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAS25pZ2h0SGFja2VyMjA3Nw==,size_19,color_FFFFFF,t_70,g_se,x_16)
Business Rules
- Come from company policy
- Dictate how buiness is conducted
- Included to support Alt. flow
Example
Precondition
Invariants
- Use Case: Make Payment
- Invariant: Actor stays authorized