Power Point Presentation for 06cs71 Oomd Chapter 6 Yr 2009 Kss
-
Upload
praveen-reddy -
Category
Documents
-
view
664 -
download
2
Transcript of Power Point Presentation for 06cs71 Oomd Chapter 6 Yr 2009 Kss
Advanced State Modeling/Ch 6
06CS71/OOMD 6.11
06CS71:Object-Oriented Modeling and Design with
UML Chapter-06: Advanced State Modeling
ByKumara swamy S
Department of Computer Science & Information science
and Engg
Advanced State Modeling/Ch 6
06CS71/OOMD 6.2
Teaching Points
• Nested State Diagrams• Nested States• Signal Generalization • Concurrency • A Simple State Model• Relation of Class and State Models• Summary
Advanced State Modeling/Ch 6
06CS71/OOMD 6.3
Nested State Diagramproblems with flat state diagrams
• Flat state diagrams are impractical for large problems.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.4
Expanding States
• A high-level diagram with subdiagrams expanding certain states.
A submachine of VendingMa
chine
Advanced State Modeling/Ch 6
06CS71/OOMD 6.5
Expanding States
• A submachine is a state diagram that may be invoked as part of another state diagram.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.6
Teaching Points
• Nested State Diagrams• Nested States• Signal Generalization • Concurrency • A Simple State Model• Relation of Class and State Models• Summary
Advanced State Modeling/Ch 6
06CS71/OOMD 6.7
Nested States
• To show the composite state’s commonality and share behavior.
• The composite state name labels the outer contour that entirely encloses the nested states
• E.g., Active
Advanced State Modeling/Ch 6
06CS71/OOMD 6.8
Advanced State Modeling/Ch 6
06CS71/OOMD 6.9
Advanced State Modeling/Ch 6
06CS71/OOMD 6.10
Nested States• Each of the nested states receives the outgoing
transitions of its composite state.
• State First, Second, and Third are nested states of state Forward.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.11
Advanced State Modeling/Ch 6
06CS71/OOMD 6.12
Advanced State Modeling/Ch 6
06CS71/OOMD 6.13
Definitions
• A substate is a state that is nested in another state
• A state that has substates is called a composite state
• A state that has no substates is called a simple state
• Substates may be nested to any level
Advanced State Modeling/Ch 6
06CS71/OOMD 6.14
Teaching Points
• Nested State Diagrams• Nested States• Signal Generalization • Concurrency • A Simple State Model• Relation of Class and State Models• Summary
Advanced State Modeling/Ch 6
06CS71/OOMD 6.15
Signal Generalization
• A signal hierarchy permits different levels of abstraction to be used in a model.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.16
Teaching Points
• Nested State Diagrams• Nested States• Signal Generalization • Concurrency • A Simple State Model• Relation of Class and State Models• Summary
Advanced State Modeling/Ch 6
06CS71/OOMD 6.17
Concurrency
• The state model implicitly supports concurrency among objects.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.18
Aggregation Concurrency
• The aggregate state corresponds to the combined states of all the parts.
• 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.
• Transition for one object can depend on another object being in a given state.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.19
The state of the car includes one state from each part.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.20
Concurrency within an Object
• Some objects can be partitioned into subsets of attributes or links.
• Each of the partitioned subset has its own subdiagram.
• The state of the object comprises one state from each subdiagram.
• The subdiagrams need not be independent; the same event can cause transitions in more than on subdiagram.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.21
A Gas Station Example
• Let's take a simple example, so we can draw the diagram
• When you go to a full service gas station, the attendants will begin to:– Wash your windshield– Fill your gas tank– Check your oil, and other fluids– Check your tires
Advanced State Modeling/Ch 6
06CS71/OOMD 6.22
A Gas Station Example
• If there are multiple attendants, you would assume that they would perform these acts in parallel
• Thus, when you arrive at the station, the path of execution will be split– Let's simplify the example (for visual reasons) and say
that only two things happen:• Fill your tank• Wash your windshield
Advanced State Modeling/Ch 6
06CS71/OOMD 6.23
A Gas Station Example
In Service
arrive depart
beginWash WashingWindshield
endWash
pumpGas FillingGas Tank
tankFull
Advanced State Modeling/Ch 6
06CS71/OOMD 6.24
Concurrent State Diagrams
• The example used a embedded state diagram to handle concurrency– The state 'In Service' contained two concurrent
threads of execution– The thread of execution splits when we enter
'In Service' state, and joins when we exit 'In Service' state
• Without embedded state diagrams, we can still represent concurrency
Advanced State Modeling/Ch 6
06CS71/OOMD 6.25
A Gas Station Example
arrive depart
beginWash WashingWindshield
endWash
pumpGas FillingGas Tank
tankFull
Advanced State Modeling/Ch 6
06CS71/OOMD 6.26
A Gas Station Example
arrive depart
beginWash WashingWindshield
endWash
pumpGas FillingGas Tank
tankFull
Divergence Convergence
Advanced State Modeling/Ch 6
06CS71/OOMD 6.27
Concurrency within an Object
Advanced State Modeling/Ch 6
06CS71/OOMD 6.28
Concurrency within an Object
• The play of a bridge rubber
Advanced State Modeling/Ch 6
06CS71/OOMD 6.29
Concurrent Composite State Example
NormalOperation
EW Greenafter 40 sec
EW Amberafter 5 sec
EW Red
NS Redafter 45 sec
NS Greenafter 30 sec
NS Amber
after 35 sec
after 5 sec
Advanced State Modeling/Ch 6
06CS71/OOMD 6.30
Synchronization of Concurrent Activities
• Sometimes one object must perform two ( or more) activities concurrently.
• The object must complete both activities before it can progress to its next state.
Splitting
control
Merging
control
Advanced State Modeling/Ch 6
06CS71/OOMD 6.31
Entering Selected Concurrent States: Illustration
Concurrent Composite State
S1 ...
S2 ...
S4 ...
SourceState
transitionString
S3 ...
Advanced State Modeling/Ch 6
06CS71/OOMD 6.32
Leaving Selected Concurrent States: Illustration
Concurrent Composite State
S1...
S2...
S4...
Target State
transitionString
S3...
...
...
Advanced State Modeling/Ch 6
06CS71/OOMD 6.33
State Diagram –UML notation
Advanced State Modeling/Ch 6
06CS71/OOMD 6.34
A Sample State Model
• A programmable thermostat controls a furnace and air conditioner to keep the current temperature equal to the target temperature.
• The user programs the thermostat using a pad of ten pushbuttons and three switches.
• Each pushbutton generates an event every time it is pushed.
• Each switch supplies a parameter value chosen from two or three possibilities.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.35
A Sample State Model
• A Programmable Thermostat – The device controls a furnace and air
conditioner according to time-dependent attributes that the owner enters using a pad of buttons.
– User can specify eight target temperature, four on weekdays and four on weekends.
– Each target temperature has a start time and a time period.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.36
A Sample State Model
• Buttons– TEMP UP– TEMP DOWN– TIME FWD– TIME BACK– SET CLOCK– SET DAY– RUN PRGM– VIEW PRGM– HOLD TEMP– F-C BUTTON
• Switchs– NIGHT LIGHT– SEASON– FAN
Advanced State Modeling/Ch 6
06CS71/OOMD 6.37
Top-level state diagram
• Contain seven concurrent subdiagrams• User Interface is shown on next page
Advanced State Modeling/Ch 6
06CS71/OOMD 6.38
Example:Programmable Thermostat
Thermostat
U.I. seasonswitch
fan switch
furnace relay
A/Crelay
fanrelay
Runindictor
Example of Aggregation Concurrency
Advanced State Modeling/Ch 6
06CS71/OOMD 6.39
Advanced State Modeling/Ch 6
06CS71/OOMD 6.40
Advanced State Modeling/Ch 6
06CS71/OOMD 6.41
Advanced State Modeling/Ch 6
06CS71/OOMD 6.42
Relation of Class and State Models
• A state diagram describes all or part of the behavior of the objects of a given class.
• State structure is related to and constrained by class structure.– A composite state is the aggregation of more than
one concurrent substate.– Try to make the state diagrams of subclasses indep
endent of the state diagrams of their superclasses.
Advanced State Modeling/Ch 6
06CS71/OOMD 6.43
6.6 Relation of Class and State Models
Inherent differences among objects are properly modeled as different classes
Temporary differences are properly modeled as different states of the same class
Composite state: aggregation of more than oneconcurrent substate
Advanced State Modeling/Ch 6
06CS71/OOMD 6.44
6.6 Relation of Class and State Models
3 sources of concurrency within class model
a. Aggregation of objects…each part of an aggregation has its own independent state…assembly has state that is the combination of the states of all its parts
b. Aggregation within an object…values and links areits parts…groups of them define concurrent substates of the composite object state
c. Concurrent behavior of an object figure 6.9
Advanced State Modeling/Ch 6
06CS71/OOMD 6.45
Quiz
• o p c e m t i o s e a t t s • n y e r r o u n c c c• e e d n s t e a t t s a a d m i g r • g n l a s i a l i i o n n e e z g a t r• n i n c o n z a t i s y o h r • h m s c b i u n e a
Advanced State Modeling/Ch 6
06CS71/OOMD 6.46
Solution to Exercise 6.1
Advanced State Modeling/Ch 6
06CS71/OOMD 6.47
Solution to Exercise 6.6
Advanced State Modeling/Ch 6
06CS71/OOMD 6.48
Advanced State Modeling/Ch 6
06CS71/OOMD 6.49
References
• Object-Oriented Modeling and Design with UML by Michael Blaha, 2nd edition, Pearson Education
• WWW
Advanced State Modeling/Ch 6
06CS71/OOMD 6.50
Sol 6.12
Advanced State Modeling/Ch 6
06CS71/OOMD 6.51