Professional Documents
Culture Documents
1
Recap
• Formal Use Case diagram
• UML notation for use cases
• Examples
2
Contents
• Introduction to UML Activity Diagrams
• Concepts of Action, Pins and Activity
• Description of activity nodes and activity edges
• New notations
– Activity Partition
– Pre & post condition
– Send Signal Action
– Time triggers and Time events
– Accept Event Action
– Interruptible ActivityRegion
– Exception
– ExpansionRegion
– Swim lanes
3
When to Use Activity Diagrams
• Do use them for
– Analysing Use Cases.
– Understanding workflow across many Use Cases.
– Dealing with multi-threaded applications.
• Don’t use them
– to see how objects collaborate.
– to see how an object behaves over its lifetime.
Placing an Activity diagram
• Where?
– You can attach activity diagrams to most model elements
in the use case or logical views.
– Activity diagrams cannot reside within the component
view.
• Why?
– Very effective in illustrating the workflow of various events
in a use-case diagram.
– You can use activity diagrams to specify and define each
event in a use-case diagram.
Creating an activity diagram
• Modelling a workflow in an activity diagram
– Identify a workflow objective.
– Decide the pre and post-conditions of the workflow.
– Define all activities and states.
– Define any objects that are created or modified.
– Decide on responsibility for performing the activities.
– Connect all elements on the diagram with transitions.
– Place decisions on the diagram.
– Evaluate your diagram for concurrent workflows.
– Set all actions, triggers and guard conditions in the
specifications of each model element.
Activity Diagrams
• An activity diagram is a special case of a state
chart diagram
• The states are activities (“functions”)
• An activity diagram is useful to depict the
workflow in a system
7
Activity Diagram
• Serves as a technique to describe procedural logic, business
process logic, and work flow
• Is similar to a flowchart except that it can also show parallel
behavior
• States the essential sequencing rules to follow, thereby
allowing concurrent algorithms to be used
– Consequently, an activity diagram allows whoever is doing the
process to choose the order in which to do certain things
• Can be used to describe the actions in a use case
8
Example Activity Diagram
Set counter = positive n
Set accumulator = initial value
F
n>1
T
Set accumulator = accumulator * n
Set n = n - 1
F (n mod 5) == 0
T
Display accumulator value
[order reject]
Send Accept
Invoice Make Payment
Invoice Payment
10
Some Definitions
• Flow: permits the interaction between two nodes of the activity
diagram (represented by edges in activity diagram)
• State: a condition or situation in the life of an object during which it
satisfies some conditions, performs some activities, or waits for some
events
• Type: specifies a domain of objects together with the operations
applicable to the objects (also none); includes primitive built-in types
(such as integer and string) and enumeration types
• Token: contains an object, datum, or locus of control, and is present
in the activity diagram at a particular node; each token is distinct
from any other, even if it contains the same value as another
• Value: an element of a type domain
11
Actions
• The fundamental unit of executable
functionality in an activity
• The execution of an action represents some
transformations or processes in the modeled
system (creating objects, setting attribute
values, linking objects together, invoking user-
defined behaviours, etc.)
Description of
the action
behaviour
12
Pins
• Actions can have inputs and outputs, through the pins
• Hold inputs to actions until the action starts, and hold the
outputs of actions before the values move downstream
• The name of a pin is not restricted: generally recalls the type
of objects or data that flow through the pin
Stand-alone
style
14
Special kind of pins (2)
• Parameter Sets
– group of parameters
– the action can only accept inputs
from the pins in one of the sets
– the action can only provide outputs
to the pins in one of the sets
Output is provided only to
the first or to the second set
value Compute
circumference
3.14
π
15
Conditions to start and end actions
16
Activities
• An activity is the specification of parameterized behaviour as the
coordinated sequencing of subordinate units whose individual
elements are actions
• Uses parameters to receive and provide data to the invoker
Activity
nodes
Parameter Activity Parameter Output
Input name
edges name
parameter Parameter parameter
name
Notation without
activity nodes
20
Options
• Object nodes
– multiplicities and upperBound
– effect and ordering
• Activity nodes
– presentation options
– transformation
• Selection
• Token competion
21
New notations
• ActivityPartition
• Pre & post condition
• SendSignalAction
• Time triggers and Time events
• AcceptEventAction
• InterruptibleActivityRegion
• Exception
• ExpansionRegion
22
Example – go to Genova Go to
Heaven/Hell
Car crash ;)
«local precondition»
Have a license
Fill up To Catch
Turn on [else]
with motorway the
the car
[on car] fuel tollgate ticket
[the tank is full]
Go to the
Buy the Obliterate Catch
station with
ticket the ticket the train
a friend
The train
Go to derail
Heaven/
Hell ;) The friend
goes home
When the train
arrives
to Genova
[else] Study
Go home Get off
for 5
with bus the train
minutes
23
[Genova is a long way]
Control nodes – Initial nodes
• In an activity the flow starts in initial nodes, that return the
control immediately along their outgoing edges
A or B ?
24
Control nodes – Decision nodes
• Route the flow to one of the outgoing edges (tokens are
not duplicated)
• Guards are specified on the outgoing edges or with the
stereotype «decisionInput»
• There is also the predefined guard [else], chosen only if
the token is not accepted by all the other edges
• If all the guards fail, the token remains at the source
object node until one of the guards accept it
25
Activity Diagram: Modeling
Decisions
Decision
[lowPriority]
Open Allocate
Incident Resources
Notify
Police Chief
26
Control nodes – Merge nodes
27
Activity Diagrams can model
Concurrency
• Synchronization of multiple activities
• Splitting the flow of control into multiple
threads
Allocate
Splitting Resources Synchronization
Document
Incident
28
Control nodes – Fork nodes
30
Control nodes – Final nodes
• Flow final:
– destroys the tokens that arrive into it
– the activity is terminated when all tokens in the graph are
destroyed
• Final node:
– the activity is terminated when the first token arrives
intentional race
between flows
31
Summary
• Activity Diagrams
– When to use?
– Where?
– Nodes
– Edges
– More to come ….
32