Activity Diagram

Download Report

Transcript Activity Diagram

Activity Diagram Revisited
C-S 546
1
Activity Diagram

Also called an “activity graph”, is a
variation of a state machine representing
actions and subactivities
 Remember
the difference between “activity”
and “action” in UML
 Activity : A sequence of actions that take
finite time and can be interrupted
 Action: An atomic task that cannot be
interrupted (at least from user’s perspective)
C-S 546
2
Activity Diagram (continued)

Transitions in an activity diagram do not have
labels



They indicate the completion of an action or
subactivity and show the sequence of actions or
subactivities
Consequently, these transitions are not based on
external events
An activity diagram may describe a use case, an
operation or a message

Purpose: to describe implementation-oriented details
C-S 546
3
Activity Diagram – Basic Syntax
Action 1
Action 2
Action 3
split
[C]
Action 4
[~C]
C-S 546
merge
4
Activity Diagram - semantics
Each action state must have a label;
otherwise, no information is conveyed by
that action state
 A transition can be split (see the vertical
bar) into multiple transitions that can
reach multiple action states

 These
transitions occur concurrently; in the
previous diagram, “Action 2” and “Action 3”
said to occur concurrently, after “Action 1”
C-S 546
5
Activity Diagram – Semantics
(continued)

Two or more transitions can be combined
together using a merge (the same vertical
bar notation)
 The
destination after the merge can be
reached ONLY AFTER the source actions are
completed
 In the previous diagram, if “Action 4” is
invoked, the entire activity terminates ONLY
AFTER “Action 2” and “Action 4” complete
C-S 546
6
Activity Diagram – Semantics
(continued)

An outgoing transition from an action
state may end up in a condition box (a
diamond symbol) and hence will be split
into 2 or 3 transitions
 The
conditions must be MUTUALLY
EXCLUSIVE

Action state labels may represent methods
and hence may include parameters
C-S 546
7
[No coffee]
[No cola]
Find Beverage
[found cola]
[found coffee]
Put Coffee in
Filter
Add Water
Get Cups
Get cola can(s)
Put filter in
M/c
Switch on M/c
Wait until
brewed
Pour into cup
Preparing Beverages - ©UMLC-SManual
546
version 1.5
Drink
8
false
amount > 0
report error
true
balance 
amount
false
amount –
balance  N
true
false
report error
true
balance = balance
- amount
Use case “withdraw” with overdraft protection
‘N’ represents overdraft limit
C-S 546
9
Subactivity
An action state in an activity diagram can be
represented by a subactivity as shown below
Subactivity
A subactivity represents a simplification of
another activity diagram
It reduces the space for an activity diagram
C-S 546
10
Subactivity - semantics
A subactivity is a representation of
another activity diagram
 The incoming arrow to a subactivity
matches with the initial state of the
activity diagram represented by the
subactivity
 The outgoing arrow from a subactivity
matches with the final state of the activity
diagram represented by the subactivity

C-S 546
11
Swimlanes

Several activity diagrams can be merged
into one diagram
 particularly
to show the interacting actions
between these diagrams
Each activity diagram is enclosed in a
separate box and the boxes are joined
together in the swimlane diagram
 See the example in the next slide

C-S 546
12
Customer
Sales
Stockroom
Request service
Take Order
Pay
Fill Order
Deliver order
Collect order
C-S 546
13
Objects as parameters
Objects passed as parameters between
action states can be represented in the
activity diagram (and in swimlane
diagram) using the same syntax for
objects
 The transition between an object
parameters and an action state is
represented with a dashed line, instead of
a solid line

C-S 546
14
Customer
Request service
Sales
Stockroom
: Order
[placed]
Take Order
Pay
: Order
[filled]
:Order
[entered]
Fill Order
:Order
[delivered]
Collect order
Deliver order
C-S 546
15