Object Oriented Analysis & Design & UML (Unified Modeling

advertisement
Part VI: Design Continuous
Activity Diagams
State Diagrams
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
1
Content


13.04.2015
Activity Diagams
State Diagrams
Object Oriented Analysis & Design & UML (Unified Modeling Language)
2
Activity Diagrams
3
Activity Modeling

a specialized type of behavioral modeling



a special form of state machine to model



not states of objects
applied in conjunction with

13.04.2015
the computations
and workflow
Represents the state of execution


concerned with modeling the activities
and responsibilities of elements.
sequence and collaboration modeling
Object Oriented Analysis & Design & UML (Unified Modeling Language)
4
Activity Diagrams

widely used in analysis to model




but also in design to model


13.04.2015
a use case flow
flow between the use cases
with no use of classes, objects, etc.
details of operation
details of algorithm
Object Oriented Analysis & Design & UML (Unified Modeling Language)
5
Using Activity Diagrams

activity diagram can be



Activity diagrams are typically attached to







13.04.2015
attached to any modeling element
for the purpose of modeling the behavior of that
element.
use cases
classes
interfaces
components
nodes
collaborations
operations and methods
Object Oriented Analysis & Design & UML (Unified Modeling Language)
6
Action States

Operation of Object Oriented systems


a society of objects
Elements communicate with one another

each element has



An action state processing


as an element fulfills a responsibility
Example (the project management system states)



13.04.2015
the responsibility of reacting
to the communications it receives.
Project Manager Enters Report Criteria
Project Management System Generates Report
Printer Prints Report
Object Oriented Analysis & Design & UML (Unified Modeling Language)
7
Types of action states

Initial action state


A final action state



the last action state
is shown using “a bull's eye”
An activity diagram


13.04.2015
the first action state
may have only one initial action state,
but may have any number of final action states.
Object Oriented Analysis & Design & UML (Unified Modeling Language)
8
Flow Transitions

shows how action states



are ordered
or sequenced.
Whenever


an action or subactivity state
finishes its work,



there is a transition
out of the state into the next state
types of flow transitions:


control-flow
object-flow transitions
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
9
Control-Flow Transitions

indicates


Once a source action state


completes its processing,
a target action state

13.04.2015
the order of action states
starts its processing
Object Oriented Analysis & Design & UML (Unified Modeling Language)
10
Example Control Flow Transitions

task of generating a report


for the project management system
order of action states:


The Project Manager Enters Report Criteria
The Project Management System


13.04.2015
Generates Report
The Printer Prints Report
Object Oriented Analysis & Design & UML (Unified Modeling Language)
11
Control-flow transitions
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
12
Default transitions

Control-flow transitions



are also known as default transitions
or automatic transitions,
because


they are unlabeled
and are immediately triggered


13.04.2015
after the source action state
completes processing.
Object Oriented Analysis & Design & UML (Unified Modeling Language)
13
Decisions

A decision involves

selecting one control-flow
transition


13.04.2015
out of many control-flow
transitions
based upon a condition
Object Oriented Analysis & Design & UML (Unified Modeling Language)
14
Swimlanes


a visual region in an activity
diagram
Represents




use cases
classes
components
organizational units


roles


in business modeling
in workflow modeling
indicates the element


has responsibility
for action states within the
region
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
15
Object-Flow Transitions

Indicates an action
state



input or output an
object
can modify object state
An object-flow
transition

is shown as


a dashed arrow
between


an action state
and an object.
Activities may input and output objects and can modify object state
show this on an activity diagram as an object flow
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
16
Types of Object-Flow Transitions

An action state uses an object as input:


show with object-flow transition arrow
Point



An action state updates or produces an object:


Show with the object-flow transition arrow
Point


13.04.2015
from the object
to the action state.
from the action state
to the object
Object Oriented Analysis & Design & UML (Unified Modeling Language)
17
Control-flow and object-flow transitions
Without unnecessary control-flow transitions
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
18
Signals

A signal is a way of representing


a package of information
that is communicated asynchronously


A signal event occurs


when an object receives a signal
When an event is received


13.04.2015
between two objects.
by an object
it may trigger a state transition in it
Object Oriented Analysis & Design & UML (Unified Modeling Language)
19
Sending & Receiving Signals

the signal called
Order is sent to the


:MailOrderCompany
external object
we wait in the signal
receipt

for a signal called
Goods delivered
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
20
Signals are classifiers


Modeled as stereotyped classes.
The purpose of a signal is



to provide asynchronous communication of information
between objects and so,
unlike ordinary classes,


they only have attributes
and the single implicit operation



send(targetSet)
allows them to be sent to a set of target objects.
As this operation is implicit,



The signal attributes

13.04.2015
it is never actually shown on signal diagrams
it is just assumed that it is there for every signal.
specify the information content of the signal
Object Oriented Analysis & Design & UML (Unified Modeling Language)
21
Example: GUI events
a generalization hierarchy of raw GUI events modeled as signals
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
22
Concurrency

13.04.2015
selecting multiple transitions simultaneously
Object Oriented Analysis & Design & UML (Unified Modeling Language)
23
State Diagrams
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
24
State Diagrams

also known as



depict the lifecycle of elements


statechart diagrams
state machines (in UML 2.0)
that make up a system
State modeling


is a specialized type of behavioral modeling
concerned with modeling

13.04.2015
the lifecycle of an element
Object Oriented Analysis & Design & UML (Unified Modeling Language)
25
States: Definition

A state


is a condition of being at a certain time.
is drawn as a rounded rectangle


with the name of the state in the center
can be

a passive quality,


an active quality (object is doing something


13.04.2015
Example: light object=> On and Off.
Example: Person => moving, sleeping, reading, …
Example: coffeemaker => Brewing
Object Oriented Analysis & Design & UML (Unified Modeling Language)
26
Simple States


indicates a condition or situation of an element.
Example:




the project management system
Inactive
 is not available to its users,
 because it is not started or has been shut down
Active
 started and available to its users
Suspended
 has encountered some severe error,

Possible reason:


13.04.2015
is running low on secondary storage
requires user intervention
Object Oriented Analysis & Design & UML (Unified Modeling Language)
27
Initial and Final States

Initial state

the state of an element ,



when it is created.
is shown with a small solid filled circle.
A final state

the state of an element


is shown with


13.04.2015
when it is destroyed.
a circle surrounding a small solid filled
circle
a bull's eye
Object Oriented Analysis & Design & UML (Unified Modeling Language)
28
Transitions

A transition,


shown with an arrow
represents



a change of states
from a source state to a
target state
A transition description,


written along the arrow,
describes the
circumstances

13.04.2015
causing the state change to
occur.
Object Oriented Analysis & Design & UML (Unified Modeling Language)
29
Trigger

A trigger is



an event cause a transition.
Example:
User input processing systems

a keystroke trigger

may cause the system to change states


13.04.2015
from Gathering input
to Processing input.
Object Oriented Analysis & Design & UML (Unified Modeling Language)
30
Transition Variations

A trigger with no guard

the transition is taken


This is useful



for modeling a state change
in response to an event.
A trigger with a guard

the transition is taken




when the trigger occurs
if the guard evaluates to true.
Otherwise, the transition isn't taken.
Combining a trigger and a guard is
useful



when the trigger occurs.
for modeling a transition is blocked
depending on a condition.
Neither a trigger nor a guard are
specified,


the transition is taken immediately
after the source state's internal
behavior
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
31
The life cycle of an object

the life cycle of an AccountApplication object



13.04.2015
as it passes from pending
to approved or rejected
and then to finalizing
Object Oriented Analysis & Design & UML (Unified Modeling Language)
32
Example how to use

State diagram modeling a troll in a FPS game


13.04.2015
FPS: first-person shooter
the troll's behavior is determined by his state
Object Oriented Analysis & Design & UML (Unified Modeling Language)
33
Composite States

A composite state is a state


contains one or more state diagrams.
Each diagram belongs to a region,


A state in a region is referred to as a


substate of the composite state.
Composite states work as follows:


when the composite state becomes active,
the initial pseudostate of each region becomes active,


and the contained state diagrams begin executing.
if a trigger on the composite state occurs

13.04.2015
regions are divided by a dotted line
The contained state diagrams are interrupted
Object Oriented Analysis & Design & UML (Unified Modeling Language)
34
Composite States Example

Composite states contain


13.04.2015
one or more state diagrams;
execute in parallel
Object Oriented Analysis & Design & UML (Unified Modeling Language)
35
Advanced Pseudostates

A choice pseudostate



determines
 which transition is followed.
has guards


13.04.2015
used to emphasize a Boolean condition
represented on outgoing transitions
the transition depends on the guard.
Object Oriented Analysis & Design & UML (Unified Modeling Language)
36
Fork and join pseudostates

show branching


13.04.2015
into concurrent states
and then rejoining
Object Oriented Analysis & Design & UML (Unified Modeling Language)
37
Signals

transition-oriented view:

to draw attention


13.04.2015
to transitions and transition behavior
using special icons for transitions.
Object Oriented Analysis & Design & UML (Unified Modeling Language)
38
End of Chapter
13.04.2015
Object Oriented Analysis & Design & UML (Unified Modeling Language)
39
Download