3.1.advanced State Modeling Concepts
3.1.advanced State Modeling Concepts
CSE307
Object Oriented Analysis & Design
1
Introduction
• Conventional state diagrams are
sufficient for describing simple systems.
• But need additional power to handle
large problems.
2
Introduction
• You can more richly model complex
systems by using:
– Nested state diagrams,
– Nested states,
– Signal generalization, and
– Concurrency.
3
Nested state diagrams
• State diagrams are impractical for large problems especially
when they become flat and unstructured.
4
Nested state diagrams
• Consider an object with n independent Boolean
attributes that affect control.
• Representing such an object with a single flat
state diagram would require 2n states.
• An object with 3 Boolean attributes can be drawn
using flat state diagram :
• No of states will be : 2n ; n=3; 6 states with n2
transitions ; 9 transitions.
5
Expanding States
• One way to organize a model is by having a
high-level diagram with sub diagrams
expanding certain states.
• A submachine is a state diagram that may be
invoked as part of another state diagram.
6
Nested State Diagrams
• An activity in a state can be expanded as a
lower level state diagram
• Nested activities are one shot diagrams with
input and output transitions, like subroutines.
• The following diagram shows a top-level
model for a vending machine.
7
High level vending machine model
SubMachine
8
High level vending machine model
9
Nested States
• Composite State:
– Entirely encloses the nested states.
– it’s a name label of outer contour(form) that encloses
the nested state
– A nested state receives the outgoing transitions of its
composite state.
• Example:
– Nested states refines values and link that object can
have.
– In phone line diagram, all state except idle are
nested state as active.
10
Nested states for a phone line : A nested state receives
the outgoing transitions of its enclosing state.
Active is a composite
state with regard to
nested states
DialTone, Timeout and
Dialing
11
Nested States:
An automobile automatic transmission
• The transmission can be reverse, neutral or
forward
• Forward first, second and third gears
12
Nested state diagrams
• State diagrams can be structured to permit
concise descriptions of complex systems.
• It allows generalization and aggregation
• Generalization is equivalent to expanding
nested activities.
• Aggregation allows concurrency of states.
13
Signal Generalization
• you can organize signals into a generalization
hierarchy with inheritance of signal attributes.
• A signal hierarchy permits different levels of
abstraction to be used at different places in a
model.
14
Signal Generalization
15
Concurrency
• Object can act and change state independent
of one another.
• Sometime objects shares constraints that
causes their state changes
• A state diagram for an assembly is a collection
of state diagrams.
16
Concurrency
1. Aggregation Concurrency
• second State Aggregation means collection of state diagram ,
one for each part
• Aggregate state is one state from first diagram and a state
from diagram and state from each other diagram.
17
An aggregation and its concurrent state diagrams
The state
diagram for an
assembly is a
collection of
state diagrams
18
Concurrency
2. Concurrency within an object
• Some objects can be partitioned into subsets of
attributes or links.
• Concurrency within a single state of an object
shown by partitioning the composite state into
sub diagram with dotted lines.
• The name of the state can be written in a
separate region of the box, separated by a solid
line
19
Sample State Diagram:
Programmable thermostat
20
Sample State Diagram:
Programmable
thermostat
21
Sample State Diagram:
Programmable
thermostat
22
Relation of Class and
State Models
• The state model specifies allowable sequences of
changes to objects from the class model.
• A state diagram describes all or part of the behaviour
of the objects of a given class.
• Both generalization of classes and nesting of states
partition the set of possible object values.
• A composite state is the aggregation of more than one
concurrent substate.
– There are three sources of concurrency within the class
model.
– aggregation of objects , aggregation within an object,
concurrent behavior of an object
23
Relation of Class and
State Models
• The subclasses can have their own state
diagrams
• The state diagram of the subclass involves
some of the same attributes as the state
diagram of the super class.
• The subclasses can have their own state
diagrams.
• Transitions can often be implemented as
operations on objects.
24