0% found this document useful (0 votes)
5 views

l2 Umlactivity

Diagrams on uml and other activities
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

l2 Umlactivity

Diagrams on uml and other activities
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

UML Activity Diagrams,

State-Machine Diagrams and


Modelling
Lecture # 2

Department of Computer Science and Technology


University of Bedfordshire
Written by David Goodwin,
based on the book Applying UML and Patterns (3rd ed.)
by C. Larman (2005).

Modelling and Simulation, 2012


UML Activity
Outline Diagrams,
State-Machine
Diagrams and
Modelling

Activity Diagrams
Introduction Activity
Activity Diagrams - notation Diagrams
Introduction
How to apply activity diagrams Activity Diagrams
- notation
Guidelines How to apply
activity diagrams
Guidelines

State-Machine Diagrams State-Machine


Diagrams
Introduction Introduction

State-Machine Diagrams - notation State-Machine


Diagrams -

How to apply state-machine diagrams notation


How to apply
state-machine
diagrams

Further Examples Further


Examples
UML Activity
Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction

Activity Diagrams Activity Diagrams


- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
What is an Activity Diagram” UML Activity
Diagrams,
State-Machine
Diagrams and
Modelling
I An Activity Diagram is on of the Behaviour diargams.
I Activity modelling is the sequence and conditions for
coordinating lower-level behaviours, rather than which
classifiers own those behaviours. Activity
Diagrams
I These are commonly called control flow and object flow Introduction

models. Activity Diagrams


- notation

I The behaviours coordinated by these models can be How to apply


activity diagrams

initiated because other behaviours finish executing, Guidelines

because objects and data become available, or because State-Machine


Diagrams
events occur external to the flow. Introduction
State-Machine
I A UML Activity Diagram shows sequential and parallel Diagrams -
notation
activities in a process. How to apply
state-machine
I Useful for modelling: diagrams

I Business processes Further


Examples
I Workflows
I Data flows
I Complex algorithms
UML Activity
Basic UML Activity Diagram notation Diagrams,
State-Machine
Diagrams and
Modelling

Action It does something. There is automatic


transition on its completion. A transition Activity
(arrows between actions) supports modelling of Diagrams
Introduction
control flow. Activity Diagrams
- notation
Fork One incoming transition, and multiple outgoing How to apply
activity diagrams
parallel transitions and/or object flows. Guidelines

Join Multiple incoming transitions and/or object State-Machine


Diagrams
flows; one outgoing transitions. The outgoing Introduction
State-Machine
continuation does not happen until all the Diagrams -
notation
inputs arrive from all flows. How to apply
state-machine
Object Node An object produced or used by actions. This diagrams

allows us to model data flows or object flows. Further


Examples
UML Activity
Initial and Final Nodes Diagrams,
State-Machine
Diagrams and
Modelling
I Initial Node:
I An initial node is a control node at which flow starts
when the activity is invoked.
I An activity may have more than one initial node. Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
I Final Node: Introduction
State-Machine
I An activity may have more than one activity final node; Diagrams -
notation
the first one reached stops all flows in the activity. How to apply
state-machine
diagrams

Further
Examples
UML Activity
Action Diagrams,
State-Machine
Diagrams and
Modelling
I Action:
I An action represents a single step within an activity that
is not further decomposed within the activity.
I An activity represents a behaviour that is composed of Activity
individual elements that are actions. Diagrams
I An action is simple from the point of view of the Introduction
Activity Diagrams
activity containing it, but may be complex in its effect - notation

and not be atomic. How to apply


activity diagrams
I An activity can be reused in many places, whereas an Guidelines

instance of an action is only used once at a particular State-Machine


Diagrams
point in an activity. Introduction
I An action will not begin execution until all of its input State-Machine
Diagrams -
conditions are satisfied. notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Merge and Decision Nodes Diagrams,
State-Machine
Diagrams and
Modelling
I Merge Node:
I A merge node is a control node that brings together
multiple alternate flows.
I It is not used to synchronize concurrent flows but to Activity
Diagrams
accept one among several alternate flows. Introduction

I A merge node has multiple incoming edges and a single Activity Diagrams
- notation
outgoing edge. How to apply
activity diagrams
I Decision Node: Guidelines

I A decision node accepts tokens on an incoming edge State-Machine


Diagrams
and presents them to multiple outgoing edges. Introduction
I Which of the edges is actually traversed depends on the State-Machine
Diagrams -
evaluation of the guards on the outgoing edges. notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Join and Fork Nodes Diagrams,
State-Machine
Diagrams and
Modelling
I Join Node:
I A join node is a control node that synchronizes multiple
flows.
I A join node has multiple incoming edges and one Activity
outgoing edge. Diagrams
Introduction
I Fork Node: Activity Diagrams
- notation
I A fork node is a control node that splits a flow into How to apply
multiple concurrent flows. activity diagrams
Guidelines
I A fork node has one incoming edge and multiple
State-Machine
outgoing edges. Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Object Node Diagrams,
State-Machine
Diagrams and
Modelling

I Object Node:
I An object node is an activity node that indicates an Activity
instance of a particular classifier, possibly in a particular Diagrams

state, may be available at a particular point in the Introduction


Activity Diagrams
activity. - notation

I Object nodes can be used in a variety of ways, How to apply


activity diagrams

depending on where objects are flowing from and to. Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Note Diagrams,
State-Machine
Diagrams and
Modelling

I Note: Activity
Diagrams
I A note (comment) gives the ability to attach various Introduction
remarks to elements. Activity Diagrams
- notation
I A comment carries no semantic force, but may contain How to apply
information that is useful to a modeller. activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Buisness Process Modelling Diagrams,
State-Machine
Diagrams and
Modelling

Activity
I Example: Parcel shipping Diagrams
I The process of shipping a parcel is non-trivial; there are Introduction
Activity Diagrams
many parties involived (customer, driver,. . . ) and many - notation
How to apply
steps. activity diagrams
I The process can be captured by a Use Case diagram, Guidelines

but activity diagrams are great example of “a picture State-Machine


Diagrams
being worth a thousand words”. Introduction
I Object nodes are useful for illustrating what is moving State-Machine
Diagrams -
around. notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Activity Diagram Parcel shipping Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Guideline for Activity Modelling Diagrams,
State-Machine
Diagrams and
Modelling

I The technique proves most valuable for very complex


Activity
processes, usually involving many parties. Diagrams
Introduction
I On a first overview “level 0” diagram, keep all the Activity Diagrams
- notation
actions at a very high level of abstraction, so that the How to apply
activity diagrams
diagram is short. Then expand details in sub-diagrams Guidelines

at the “level 1” level,. . . etc. State-Machine


Diagrams
I Try to make the level of abstraction of action nodes Introduction

roughly equal withn a diagram (Very different levels of State-Machine


Diagrams -

abstraction might be a node labelled “Deliver Order” notation


How to apply
and a node labelled “Calculate Tax”). state-machine
diagrams

Further
Examples
UML Activity
Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams

State-Machine Introduction
Activity Diagrams
- notation

Diagrams How to apply


activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
What is a State-Machine Diagram” UML Activity
Diagrams,
State-Machine
Diagrams and
Modelling

I State-Machine Diagrams specify state machines.


I As with Activity Diagrams, UML State-Machine
Diagrams show a dynamic flow. Activity
Diagrams
I The UML includes notation to illustrate events and Introduction

states of things (transactions, Use Cases, Activity Diagrams


- notation
people,. . . etc.). How to apply
activity diagrams
I An event is a significant or noteworthy occurence e.g. a Guidelines

telephone receiver is taken off the hook. State-Machine


I A state is the condition of an object at a moment in Diagrams
Introduction
time e.g. a telephone is in the state of being “idle” State-Machine
after the receiver is place on the hook and until it is Diagrams -
notation
taken off the hook. How to apply
state-machine
I A transition is a relationship between two states that diagrams

indicates when an event occurs e.g. when the event “off Further
Examples
hook” occurs, transition the telephone from “idle” to
“active” state.
UML Activity
Initial Pseudo State and Final State Diagrams,
State-Machine
Diagrams and
Modelling
I Initial Pseudo State:
I An initial pseudostate represents a default vertex that is
the source for a single transition to the default state.
I There can be at most one initial vertex in a region. Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
I Final State: Introduction
State-Machine
I A special kind of state signifying that the enclosing Diagrams -
notation
region is completed, leading to the entire state machine How to apply
being completed. state-machine
diagrams

Further
Examples
UML Activity
State Diagrams,
State-Machine
Diagrams and
Modelling
I State:
I A state models a situation during which some (usually
implicit) invariant condition holds.
I The invariant may represent a static situation such as Activity
Diagrams
an object waiting for some external event to occur. Introduction
I However, it can also model dynamic conditions such as Activity Diagrams
- notation
the process of performing some behaviour (i.e., the How to apply
model element under consideration enters the state activity diagrams
Guidelines
when the behaviour commences and leaves it as soon as
State-Machine
the behaviour is completed). Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Choice Diagrams,
State-Machine
Diagrams and
Modelling

I Choice:
I choice vertices result in the dynamic evaluation of the Activity
guards of the triggers of its outgoing transitions. Diagrams
I It allows splitting of transitions into multiple outgoing Introduction
Activity Diagrams
paths. - notation

I If more than one of the guards evaluates to true, an How to apply


activity diagrams
arbitrary one is selected. If none of the guards evaluates Guidelines

to true, then the model is considered ill-formed. (To State-Machine


Diagrams
avoid this define one outgoing transition with the Introduction
predefined else guard for every choice vertex). State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Join and Fork Diagrams,
State-Machine
Diagrams and
I Join: Modelling

I Join vertices serve to merge several transitions


emanating from source vertices in different orthogonal
regions.
Activity
I The transitions entering a join vertex cannot have Diagrams
guards or triggers. Introduction

I Fork: Activity Diagrams


- notation
I Fork vertices serve to split an incoming transition into How to apply
activity diagrams
two or more transitions terminating on orthogonal Guidelines
target vertices. State-Machine
I The segments outgoing from a fork vertex must not Diagrams
Introduction
have guards or triggers. State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Transition Diagrams,
State-Machine
Diagrams and
Modelling
I Transition:
I A transition is a directed relationship between a source
vertex and a target vertex.
I It may be part of a compound transition, which takes Activity
the state machine from one state configuration to Diagrams

another, representing the complete response of the state Introduction


Activity Diagrams
machine to an occurrence of an event of a particular - notation

type. How to apply


activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Note Diagrams,
State-Machine
Diagrams and
Modelling

I Note: Activity
Diagrams
I A note (comment) gives the ability to attach various Introduction
remarks to elements. Activity Diagrams
- notation
I A comment carries no semantic force, but may contain How to apply
information that is useful to a modeller. activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
State-Independent and State Diagrams,
State-Machine
Dependent Objects Diagrams and
Modelling

Activity
Diagrams
Introduction
I If an object always responds the same way to an event, Activity Diagrams
then it is considered state-independent with respect to - notation
How to apply
that event. activity diagrams
Guidelines
I If for all events of interest an object always reacts the State-Machine
Diagrams
same way, it is a state-independent object. Introduction

I By contrast state-dependent objects react differently State-Machine


Diagrams -
notation
to events depending on their state. How to apply
state-machine
diagrams

Further
Examples
UML Activity
State-Independent and State Diagrams,
State-Machine
Dependent Objects Diagrams and
Modelling

Activity
I Business information systems have few state-dependent Diagrams
Introduction
classes, so it is not helpful to apply a state machine Activity Diagrams
- notation
modelling. How to apply
activity diagrams
I Process control, device control, protocol handlers, and Guidelines
telecommunication domains often have many State-Machine
state-dependent objects; state machine modelling would Diagrams

be useful in these cases. Introduction


State-Machine
I e.g. a telephone is state-dependent; the phone’s Diagrams -
notation

reaction to pushing a particular button depends on the How to apply


state-machine
current mode of the phone (off hook, engaged,. . . etc). diagrams

Further
Examples
UML Activity
Example: Booking a psychiatrist Diagrams,
State-Machine
appointment Diagrams and
Modelling

Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction

Further Examples Activity Diagrams


- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Recycling machine - deposit items Diagrams,
State-Machine
Diagrams and
Modelling

I When a customer returns his/her first deposit item, the


machine will register the customer. Activity
Diagrams
I The machine will measure the returned item. The Introduction

measurements are used to determine what kind of can, Activity Diagrams


- notation
bottle or crate has been returned. If acceptable, the How to apply
activity diagrams
total number of items and the total value of this type Guidelines

returned by the customer increments. State-Machine


Diagrams
I When the customer presses the receipt button, the Introduction
State-Machine
printer prints the date. The total number of items he Diagrams -
notation
returned and the lump sum is calculated. The How to apply
state-machine
followings are printed out: customer number, number diagrams

returned, deposit value, total of this type and lump sum. Further
Examples
UML Activity
Recycling Activity Diagrams Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
Recycling machine - changing Diagrams,
State-Machine
values. . . Diagrams and
Modelling

Activity
I When an operator changes items’ values, the machine Diagrams

should first display a menu which contains three Introduction


Activity Diagrams
options: crate, can and bottle. - notation
How to apply
I When the operator chooses one option, the machine activity diagrams
Guidelines
should display the current value of the corresponding State-Machine
item and a range in which the value can vary. Diagrams
Introduction
I If the operator enters a value that is within the range, State-Machine
Diagrams -
the machine will ask the operator to confirm the notation
How to apply
change and then update the value of the item stored in state-machine
diagrams
the machine. Further
Examples
UML Activity
ATM Use Case Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
ATM State-machine diagrams Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
ATM State-machine diagrams Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples
UML Activity
ATM State-machine diagrams Diagrams,
State-Machine
Diagrams and
Modelling

Activity
Diagrams
Introduction
Activity Diagrams
- notation
How to apply
activity diagrams
Guidelines

State-Machine
Diagrams
Introduction
State-Machine
Diagrams -
notation
How to apply
state-machine
diagrams

Further
Examples

You might also like