Use Cases
Use Cases
Actor
ReadTime
SetTime
WatchUser WatchRepairPerson
ChangeBattery
Exit condition:
• Passenger has ticket.
Anything missing?
Exceptional cases!
The <<extends>> Relationship
• <<extends>> relationships
represent exceptional or seldom
invoked cases.
Passenger • The exceptional event flows are
factored out of the main event
flow for clarity.
• Use cases representing
PurchaseTicket exceptional flows can extend
more than one use case.
<<extends>> • The direction of a <<extends>>
relationship is to the extended
<<extends>>
use case
<<extends>>
Cancel NoChange
The <<includes>> Relationship
• <<includes>> relationship
represents behavior that is
Passenger factored out of the use case.
• <<includes>> behavior is
factored out for reuse, not
PurchaseMultiCard
because it is an exception.
PurchaseSingleTicket • The direction of a <<includes>>
<<includes>> relationship is to the using use
<<includes>> case (unlike <<extends>>
relationships).
CollectMoney
<<extends>> <<extends>>
NoChange Cancel
Use Case Diagrams: Summary
• Use case diagrams represent external
behavior
• Use case diagrams are useful as an index into
the use cases
• Use case descriptions provide meat of model,
not the use case diagrams.
• All use cases need to be described for the
model to be useful.
Use case modeling
• Use cases were developed originally to support
requirements elicitation and now incorporated into
the UML.
• Each use case represents a discrete task that
involves external interaction with a system.
• Actors in a use case may be people or other
systems.
• Represented diagramatically to provide an overview
of the use case and in a more detailed textual form.
23
Key parts of a sequence diag.
• participant: an object or entity that acts in the
sequence diagram
– sequence diagram starts with an unattached "found
message" arrow
27
Messages between objects
• message (method call) indicated by horizontal arrow
to other object
– write message name and arguments above arrow
28
Lifetime of objects
• creation: arrow with
'new' written above it
– notice that an object
created after the start of
the scenario appears
lower than the others
• deletion: an X at bottom
of object's lifeline
– Java doesn't explicitly
delete objects; they fall
out of scope and are
garbage-collected
29
Indicating method calls
• activation: thick box over object's life line; drawn when object's method is on the
stack
– either that object is running its code, or it is on the stack waiting for another
object's method to finish
– nest to indicate recursion
Activation
Nesting
30
Indicating selection and loops
• frame: box around part of a sequence diagram to indicate selection or loop
– if -> (opt) [condition]
– if/else -> (alt) [condition], separated by horiz. dashed line
– loop -> (loop) [condition or items to loop over]
opt [balance
<>0] alt [balance
< 100.00]
[balance>= 100.00]
loop [balance
< 0]
31
linking sequence diagrams
• if one sequence diagram is too large or refers to
another diagram, indicate it with either:
– an unfinished arrow and comment
– a "ref" frame that names the other diagram
– when would this occur in our system?
Approved?
32
Dependency Key Words
(De)centralized system control
• What can you say about the control flow of each of
the following systems?
– centralized?
– distributed?
34
Sequence diagram for View patient
information