Vous êtes sur la page 1sur 15

Activity Diagram Revisited

C-S 546

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 users
perspective)
C-S 546

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:

details

to describe implementation-oriented
C-S 546

Activity Diagram Basic


Syntax
Action 1

Action 2

Action 3

split

[C]

C-S 546

Action 4

[~C]

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

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

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

[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 - UML Manual version 1.58

C-S 546

Drink

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

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
C-S 546
diagram

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

Sales

Request
service

Stockroom

: Order
[placed]
:Order
[entered]

Take Order
Pay

Fill Order

: Order
[filled]
:Order
[delivered
]
Collect
order

Deliver
order

C-S 546

15