Activity Diagrams
Session Outcomes
• Introduction
• Elements of Activity diagram
• Actions
• Nodes
• Edges
• controls
• Partitioning an activity diagram
• Applying activity diagrams in real world
applications
What is an activity diagram?
Models the dynamic aspects of a
system
Plays a role similar to flowcharts
Principal difference is that they
support parallel behavior
When to Use Activity Diagrams ?
Modeling business processes
Analyzing system functionality to identify the use cases
Analyzing individual use cases in detail
Clarifying concurrency issues.
A simple Activity Diagram
data entry
generate
processing
output
Activity Diagrams Notation
Initial & Final Nodes
Beginning & end of diagram
Rounded rectangles
An activity is a sequence of actions
Transitions-Directed arrows (flow/edge)
Show sequence of activities
Example 1
Example 2
Example 3
Example 4
36
Activity Diagram Controls – Nodes
Decision Node
🞂 A branch represents a conditional flow of control.
🞂 Each branch must have a guard condition.
🞂 The flow of control flows down the single path
where the branch condition is true.
🞂 There is no limit on the number of branches each
branch point may have.
[ Guard Condition [ Guard Condition
2] 1]
[ Guard Condition
3]
🞂 always has an [else] guard expression;
37
Decision Node
🞂 The ‘else’ branch:
🞂 is taken if all the other guard conditions are false;
🞂 is analogous to the DEFAULT option in SWITCH
statement.
Activity Diagram Controls - Nodes
Decision and Merge Nodes
Decision node Merge node
Every Decision node should have
Activity Diagram Controls - Nodes
Fork and J o in
Join node used to
Fork node synchronize incoming
Has one incoming edge concurrent flow
and multiple outgoing
edges and is used to split Both Fork and Join nodes are
incoming flow into introduced to support
multiple concurrent flows. parallelism in activities
Example 5
buy food
and drinks
open wine
cook dinner
bottle
have dinner
Iteration
🞂 An asterisk inside an action state indicates that it
may need to be performed more than once:
🞂 This notation is used to show iteration, without the
unnecessary details of a loop construct.
🞂 The next action state does not occur until the loop
is finished.
Partitioning
Partitioning and Swim
Lanes
🞂 An activity partition is an activity group for
actions that have some common characteristic.
🞂 Activity partition may be shown using a
swimlane notation - with two, usually parallel
lines, either horizontal or vertical, and a name
labeling the partition in a box at one end.
Swim Lanes
🞂 Can be either horizontal or Vertical
S u b Partitioning in Swim Lanes
🞂 Order dept is a sub class under Department class
Example – Swim Lanes
Activity Draw an activity diagram for purchasing
tickets through a tickets vending machine. (train/bus)
🞂 Customer needs to buy a ticket. Ticket vending machine will
request trip information from Customer. This information will
include number and type of tickets, e.g. whether it is a monthly
pass, one way or round ticket, route number, destination or zone
number, etc.
🞂 Based on the provided trip info ticket vending machine will
calculate payment due and request payment options. Those options
include payment by cash, or by credit or debit card. If payment by
card was selected by Commuter, another actor, Bank will
participate in the activity by authorizing the payment.
🞂 After payment is complete, ticket will be dispensed to the
Customer. Cash payment might result in some change due, so the
change is dispensed to the Customer in this case. Ticket vending
machine will show some "Thank You" screen at the end of the
activity.
References
🞂 http://www.uml-diagrams.org/
🞂 U M L Distilled: A Brief Guide to the Standard Object
Modeling Language by Martin Fowler, Kendall Scott
🞂 The Complete U M L Training Course, Student
Edition by Grady Booch, et al
🞂 U M L Explained by Kendall Scott