Vous êtes sur la page 1sur 13

2/15/2013

1
STATE MODELING
INTRODUCTION
A system can be understood by first examining its
static structure that is the structure of its object s
their relationship to each other i.e. class diagram
Then you should examine changes to objects and
their relationships over time (the state model)
The state model describe the sequence of the
operation that occur in response to external
stimuli as opposed to what the operations do
what they operate on, or how they are
implemented.
TWO ELEMENTARY CONCEPTS
Events :- occurrence at a point in time
represent points in time
example user press 4
th
button of the lift .
Event correspond to verb in the past
tense(power turned on, alarm set) or to the
on set of some condition ( paper tray becomes
empty , temperature becomes lower than
freezing)
EVENT (CONTD)
One event may logically precede or follow
another or two events may be unrelated. Two
event that are casually unrelated are said to
be concurrent event.
An event is a one-way transmission of
information from one object to another. But
reply is a separate event under control of
second object. The data value convey by event
are its attribute.
2/15/2013
2
TYPES OF THE EVENT
There are three types of the events.
1. Signal event
2. Change event
3. Time event
SIGNAL EVENT
Signal event: sending/receiving information
signal is a one-way transmission of
information from one object to another.
signal is a message between object while a
signal event is a occurrence of a time.
the UML notation is the keyword signal in
guillemets (<<>>) above the signal class name
on the top of section of a box.
example of signal event
<<signal>>
flight Departure
airline
flight no.
city
state
<<signal>>
mouse button
pushed
button
location
<<signal>>
Digit dialed
digit
CHANGE EVENT
change event: caused by the satisfaction
of a Boolean expression.
The intent of change event is that expression
is continually tested-whenever the expression
changes from false to true. the event happens.
the UML notation for a change event is the
keyword when followed by a parenthesized
Boolean expression.
2/15/2013
3
example of change event
when (room temp. <heating set point)
when (room temp. > cooling set point)
when (battery power > lower limit)
TIME EVENT
Time event: caused by occurrence of an
absolute time or the elapse of a relative
time.
The UML notation :
an absolute time -> keyword when followed
by a parenthesized expression involving time.
Time interval -> keyword after followed by a
parenthesized expression that evaluate to a time
duration
example of time event
when (date= January 31,2012)
after(10 seconds)
SCENARIOS & EVENT TRACES
scenarios:
It is a sequence of events that occurs during one
particular execution of a system.
event traces:
the sequence events and the object exchanging
events can both be shown in augmented scenarios
called an event trace.
Scenarios: sequence of event
Event trace: scenarios + objects
2/15/2013
4
SCENARIO FOR PHONE CALL
caller lifts receiver
dial tone begins
caller dial digit(5)
dial tone ends
caller dial digit(5)
caller dial digit(1)
caller dial digit(2)
caller dial digit(4)
caller dial digit(3)
called phone begin ringing
ringing tone appear in calling phone
called party answer
called phone stops ringing
ringing tone disappear in calling phone
phones are connected
called party hangs up
phones are disconnected
caller hangs up
EVENT TRACE FOR PHONE CALL
caller phone line callee
caller lifts receiver
dial tone begins
dials(5)
dial tone ends
dials(5)
dials(1)
dials(2)
dials(4)
dials(3)
ringing tone phone rings
answer phone
tone stops ring stops
phone are connected phone are connected
callee hangs up
connection broken connection broken
caller hangs up
STATE
State: abstraction of values/links of an object
represent intervals of time
set of the values and links are grouped
together into a state according to gross
behavior of objects. for example the state of
bank is either solvent or insolvent depending
on whether its assets exceed its liabilities.
state are often correspond to verbs with a
suffix of ing ( waiting, dialing etc..)
State (contd)
we ignore attribute that do not effect of
behavior of the object and lump together in a
single state all combination of values and links
with the same response to events.
event represent point in time state represent
intervals of time.
Solvent dialing waiting Insolvent
2/15/2013
5
VARIOUS CHARACTERIZATION OF STATE TRANSITION & CONDITION
transition:
instantaneous change from one state to another
and caused by occurrence of an event.
For example when called phone answered the
phone line is transition; from Ringing tone
state to Connected state
the transition state is said to fire upon the
change from one source state to target state.
CONDITION
a guard condition:
it is a boolean expression that must be true in order
for a transition to occur. for example a traffic light at
an intersection may change only if road has vehicle
for wait.
a guard transition:
fires when its event occurs, but only if the guard
condition is true.
time out[cars in N/S left lanes]
time out[no cars
in N/S left lanes]
time out time out time out
[no cars in E/W
left lanes]
time out[cars in E/W left lanes]
guard transition
North/South
may go straight
East/West may
turn left
North/South
may turn left
East/West may
go straight
2/15/2013
6
STATE DIAGRAM
a state diagram is a graph whose node are
states and whose directed arcs are transitions
between states.
A state diagram specifies the state sequences
caused by event sequences.
the state model consists of multiple state
diagram. one state diagram for class with
important behavior.
contd
A state diagrams must match on their
interfaces events and guard conditions. the
individual state diagram interact by passing
events and through the side effects of guard
conditions.
ONE-SHOT STATE DIAGRAM
State diagram can represent a continuous loop
or on-shot cycles. The diagram for phone line
which is continuous loop. In describing
ordinary usage of phone we dont care how
loop is started.
A state diagram specifies the state sequence
caused by event sequences
2/15/2013
7
Contd
One shot state diagrams represent objects
with finite lives and have initial and final
states. The initial state is entered on creation
of an object entry of the final state implies
destruction of the object .
Follow figure show simplified life cycle of a
chess game with a default initial state( solid
circle) and a default final state(bulls eyes)
State diagram simple example
Checkmate
stalemate
black white
moves moves
stalemate
checkmate
Whites move
blacks move
Contd SUMMARY FOR NOTATION
2/15/2013
8
STATE DIAGRAM BEHAVIOR
Activity Effect
An effect is a reference to a behavior that
executed in response to an event. An activity
is the actual behavior that can be invoked by
any number of effects.
For example disconnect-Phone line might be an
activity that executed in response to an
onHook event
Contd
Activities can also represent internal control
operations, such as setting attributes or
generating other event.
The notation for an activity is a slash(/) and
the name (or description) of the activity,
following the event that cause it. The keyword
do is reserved for indicating an ongoing
activity and may not be an event name
DO-ACTIVITIES
A do-activity is an activity that continues for
an extended time. By definition, a do-activity
can only occur within a state and cannot be
attached to a transition.
For example the warning light may flash
during the paper jam state for an copy
machine .
2/15/2013
9
ENTRY AND EXIT ATTRIBUTES
An alternative to showing activities on
transitions, you can bind activities to entry or
to exit from a state. There is no expressive
power between two notations, but frequently
all transition into a state perform the same
perform the same activity, in which case it is
more concise to attach the activity to the
state.
NESTED STATE & Nested State
Diagram
Sometimes, we need to model an entity at
different levels of abstraction(details) so that
an entity with complex dynamic behaviours
can be modelled more appropriately.
It is often difficult to model & analyze an
object with many states using a single state
diagrams
2/15/2013
10
CONTD
Alternatively we may draw a high level state
diagram consisting of composite states and
other diagram to further elaborate the
internal state inside individual composite
states.
For each composite state we can draw its
nested states(internal states or subsets) &
their transition between them.
Use of Nested state Diagram
State Diagram can also show a Super-state for
the object.
A super-state is used when many transition
from each state to the redundant State a
super-state can be used to show that all of the
state inside of the super-state can transition to
the redundant states
This help make the state diagram easier to
read.
CONTD
GENERALIZATION EXAMPLE IN SIGNAL
2/15/2013
11
AGGREGATION CONCURRENCY
Aggregation Concurrency :
A state diagram for an assembly
is a collection of state diagram, one for each
part. The aggregation is the and relationship.
The aggregate state is one state from the
first diagram, and a state from the second
diagram , and a state from each other
diagram.
CONCURRENCY WITHITN AN OBJECT
You can partition some object into subset of
attributes or links, each of which has its own
sub diagram. The state of object is comprise
one state from each sub diagram. The UML
show concurrency within object by
partitioning the composite state into regions
with dotted lines
SYNCHRONIZATION OF CONCURRENT
ACTIVITIES
Sometimes one object must perform two (or
more) activities concurrently .
The object does not synchronize the internal
steps of the activities but must complete both
activities before it can progress to its next
state .
2/15/2013
12
EXAMPLE
RELATION OF CLASS AND STATE MODELS
The state model specifies allowable sequences
of changes to object from class model. A state
diagram describe all or part of behavior of the
object of a given class. States are equivalence
classes of values and links for an objects.
State structure is related to and constrained
by class structure. A single object can have
different states over time-the object preserves
its identity-but it cannot have different
classes.
CONTD
A composite state is the aggregation of more
than one concurrent substrate there are three
source of concurrency within the class model.
The first is aggregation of object each part of
an aggregation has its own independent state.
The superclass state diagram and the subclass
deals with disjoint of set of attributes.
CONTD
If state diagram of subclass include some of
the same attributes as the state diagram of
the super class then the state diagram of
subclass must be refinement with state
diagram of super class any state from parent
state diagram can elaborated with nesting of
split into concurrent part. But state new state
or transition cannot be introduced into parent
diagram directly.
2/15/2013
13
CONTD
The signal hierarchy is independent of class
hierarchy for classes exchanging signal. Signal
can be defined between different classes of
object.
State defined by-> interaction of object and
events
Transition defined by-> operations on object
Signal are more expressive than operation
however their effect does not depend on
classes object but its state also.
END

Vous aimerez peut-être aussi