Title: The Unified Modelling Language UML
11
The Unified Modelling Language (UML)
Activity diagrams statecharts
Modelling object behaviour Activity
diagrams Statecharts
2The Unified Modelling Language
2
Modelling Object Behaviour
Having represented the interaction between
objects through collaboration and event sequence
diagrams, we need a way of depicting the dynamic
behaviour on individual objects. This needs to
show - How objects change state and
evolve through their lifetime. What
events bring about such changes of state, and
What actions accompany such changes. This
is depicted primarily by Harrel statecharts which
are a development from traditional state
transition diagrams. At the functional level, a
more user oriented view of the processing
that takes place is provided by Activity
diagrams. These are a cross between Petri-Net
diagrams and the more traditional control flow or
workflow diagrams.
3The Unified Modelling Language
3
Harrel Statecharts
These diagrams depict the way in which objects
evolve during their life in the system. The
essential elements are - States -
representing a stable condition of the object
which persists for a
significant time (although transient states are
sometimes depicted), at a
given level of detail. Not described by verbs.
Transitions - depicting possible paths
from one state to another. Events -
these may be external events originating from
actors, or internal
events - actions performed by other objects in
the system.
Actions - processing carried out as part of a
transition in state - seen
as internal events by other objects.
Conditions - conditions governing the occurrence
of a transition.
4The Unified Modelling Language
4
Example Statecharts
The following simple statechart depicts the life
of a push/push light switch -
push/turn-on
OFF
ON
push/turn-off
Folding of states The state of an object can be
characterised entirely its location in the
diagram, but frequently this leads to an
explosion of states. These can be folded on each
other by introducing attributes, e.g. the two
ways of representing a counter -
pulse/
pulse/
pulse/
0
1
2
or, when folded with count attribute
/count0
pulse/count
counting
5The Unified Modelling Language
5
Harrel Statechart Features
The principal problems with traditional state
transition diagrams are - They
represent a single sequence of transitions - i.e.
cannot represent concurrency.
They are all at one level and tend to have many
states transitions. These are addressed with
more or less success in Harrel statecharts
by providing - A heirarchy of levels
of representation. Representation of
parallel sub-diagrams for concurrency.
Extra features such as entry, exit and do action
specifications.
6The Unified Modelling Language
6
Statechart for a simple ATM
The following represents a very simple ATM
machine and illustrates some of these features -
insert card/ prompt for pin
digit/ display
AWAIT PIN
not valid/ re-prompt
not valid 4th time/ timeout
4th digit/ validate
timeout/ eat card
IDLE
VERIFYING PIN
Enter choice/ dispense eject
AWAIT CHOICE
valid/ prompt for choice
complete
eject card/
take card/ complete
AWAIT TAKE CARD
cancel trans/ eject card
7The Unified Modelling Language
7
Statechart for a simple ATM
This becomes the following at a higher level of
abstraction-
insert card/ prompt for pin
OBTAIN PIN CHOICE
timeout/ eat card
IDLE
eject card/
take card/ complete
AWAIT TAKE CARD
cancel trans/ eject card
complete
8The Unified Modelling Language
8
Statechart for a simple ATM
Or at an even higher level of abstraction -
insert card/ prompt for pin
PROCESS TRANSACTION
timeout/ eat card
IDLE
complete
9The Unified Modelling Language
9
Statechart for diagram editor
mmnot in box/
NO BOX SELECTED
rbd/cancel line cross hair
delete/remove box lines
mm in box/ select box
mmnot in box/ de-select box
lbd in right/ select next line
mmstill in box/
BOX SELECTED
rbu/redraw box lines cross hair
confirm/ redraw box
lbd left/ display dialogue
rbdleft/ hand cursor
FILLING DIALOG
MOVING
rbdright/ circle cursor
lbdin box/ insert line cross hair
mm/ redraw box outline
LINE DRAWING
lbdnot in box/ create segment
mm/draw line segment
10The Unified Modelling Language
10
Representation of concurrency
This snippet of a domestic security system
illustrates the use of concurrent sub diagrams
with synchronising events -
ARMING do beep
ARMED
set/arm
DISABLED
trigger/ activate
enable
countgtlim/ set
cancel
GRACE PERIOD entry count0
pulse/count