ObjectOriented Analysis and Design Chapter 6 Advance State
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Advanced State Modelling © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Topic Covered • • Problem with Flat State Diagram Nested State Diagram Signal Generalization Concurrency – Aggregation concurrency – Concurrency within a object • Merging of concurrent control – Explicit – Implicit © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • Problems with flat state diagram – Problem with flat state diagrams are not able to handle large problem in precise manner. – For ex. In Phone Line state diagram, outgoing transition from each states are connected to IDLE state. – This problem is true of flat or called unstructured state diagrams. – This type of model can be reformulated using structure so number of transition could be reduced. • Expanding states. – Expanding state mean partition whole information into small number of pieces. – In other word, high-level diagram with subdiagrams expanding certain states. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling coins in(amount) / set balance Idle Cancel/ refund coins Collecting Money Coins in(amount) / add to balance [item empty] Select(item) [change<0] do / test item and compute change [change=0] dispense: Dispendseitem [change>0] do/ make change Dispense. Item arm ready do/ move arm to correct row do/ move arm to correct column pushed © RKU 2014 do/ push item off shelf arm ready Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • A submachine is a state diagram that may be invoked as part of another state diagram. • In given ex. Dispence state is submachine state which a part of Vending machine state diagram. UML notation: • To invoke a submachine, local state name followed by a colon and submachine name. • Conceptually the submachine state diagram replaces the local state. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Nested State • Simplified Phone. Line model example; a single transition from Active to Idle replaces the transitions from each state to Idle. • All the original states except Idle are nested states of Active. • Composite state name labels the outer contour that entirely encloses the nested states. • Active is a composite state with regards to nested states Dial. Tone, Time. Out, Dialing etc. • A nested state receive outgoing transition of its composite states. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Active © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling State diagram for Automobile automatic transmission Neutral push R Reverse push N push F Forward stop downshift First upshift downshift Second upshift Third • Transmission can be in reverse, neutral and forward ; • In forward, it can be in first, second or third gear – Here first, second and third are nested states of state Forward © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • Selecting “N” in any forward gear shifts a transition to neutral is going to be occur. • There are 3 transitions occur from forward to neutral; one from each forward gear. • Nested state first is the default initial state( transition indicated by solid circle) within a forward state. • Here forward is abstract state and control must be in a real state, such a first, second, and third. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • All 3 nested states share the transition on event stop. • In any forward gear, stopping the car causes a transition to first. • In simpler cases, you can draw the nested states as separates diagram and reference them by including a submachine. • You can also specifies Entry and Exit activities into nested states. • Entry activities are executed from outside in & Exit activities are executed from inside out © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Signal Generalization • It is similar to class generalization. • Organize signal into a generalization hierarchy with inheritance of signal attributes. • Fig. show tree of input signals for a workstation. • Where signals Mouse. Button and Keyboard. Character are two user input. • Both signals inherit attribute device from root signal User. Input. • Similarly, Mouse. Button. Down and Mouse. Button. Up inherit location from Mouse. Button. • You can see that every actual signal as a leaf of generalization tree. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling <<signal>> User. Input device <<signal>> Keyboard. Character character <<signal>> Mouse. Button location <<signal>> Mouse. Button. Down © RKU 2014 <<signal>> Mouse. Button. Up <<signal>> Space <<signal>> Control <<signal>> Graphic <<signal>> Alphanum <<signal>> Punctuation Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • In a state diagram, received signal triggers transitions that are defined for any ancestor signal type. • For ex. Typing an “a” would trigger a transition on signal Alpha. Num as well as signal Keyboard. Character. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Concurrency • Aggregation Concurrency – A state diagram for an assembly is collection of state diagram, one for each part. – Aggregate state corresponds to the combined states of all parts. – Aggregation is the “and-relationship” – Aggregate state is the one state from first diagram, and a state from the second diagram, and a state from each other diagram. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling push R Neutral Reverse push N push F Forward stop downshift First © RKU 2014 upshift Second downshift upshift Third Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • Transitions for one object can depend on another object. • Which allows interaction between state diagram, while preserving modularity. • State diagram of parts are almost independent. But that is not always be a case. • For ex. Car will not start unless the transmission is in neutral. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Concurrency within an object • You can partition some object into subsets or sub-regions, each of has its own subdiagram. • Subdiagram need not be independent; same event can cause transition in more than one subdiagram. • UML shows concurrency within an object, by simply partitioning a composite state into two or more regions by using dotted lines. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Timing Entry / Start Timer Do / measure duration Exit / stop timer Initializing Pause off resume [Duration > maintenance time] Pause Maintenance Overdue Timing Maintenance Overdue Sounding Alarm © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • In maintenance overdue composite state contains two concurrent states: Sounding. Alarm and Timing. Maintenance. Overdue. • So when the transition into the Maintenance Overdue composite state occurs, both substates start and run concurrently, that is, the overdue maintenance timer starts and the alarm sounds. • You can also have a transition to the composite state as shown in below figure. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • In this case, the concurrent submachines would all activate and begin to operate concurrently. • Each individual sub-region would execute beginning at the default initial state for that sub-region. • Again in this case whenever transition terminates, its terminate from both concurrent regions, because they are part of composite states. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Synchronization of concurrent Activities • Sometimes one object must perform two (or more) activities concurrently. • In this case, object does not synchronize internal steps of the activities. • But must complete both activities before it can progress to its next state. • For example, when installing any software it will test , hardware and software of system. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Example of installation © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • Software will not work properly until system hardware and software state are complete. • Hardware and software testing either in order or even simultaneously. Important thing is both should be tested. • This is an example of splitting control into concurrent activities and later merging control. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • UML shows concurrent activities within a single composite activity by partitioning a state into regions with dotted lines. • Each regions is a sub-diagram, within the composite activity. • Here, a transition that forks indicates splitting of control into concurrent parts. UML notation • Fork: Small heavy bar with one input arrow and two or more output arrows © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • Input arrow may contain event and an optional guard condition label. • While output arrows have no labels. • Each output arrows selects a states from a different concurrent diagram. • Any transition comes into a concurrent sub-diagram which activate or start each sub-diagrams. • You can also omit transitions to subdiagram. In that case, you can directly give transition to concurrent state, with each subdiagram having default initial state. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Merging of concurrent control • There are two way of merging concurrent control – Explicit merging concurrent control – Implicit merging concurrent control © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Explicit merging concurrent control • UML show explicit merging of concurrent control by a transition with two or more input arrows and one output arrow. • All arrows should connected to small heavy bar. • Target state become active when all of the source states are active and trigger event occurs. Note: Transition involves a single event, not one event per input arrow. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling • If any subdiagram in the composite state are not part of merge, it will automatically terminate when the merge transitions fires. • In other words, if any one concurrent substate is over then other concurrent substates are going to be terminate. © RKU 2014 Prepared By Ashwin Raiyani
Object-Oriented Analysis and Design Chapter 6: Advance State Modelling Implicit merging concurrent control • Unlabeled(completion) transition from the outer composite state to another state indicate implicit merging of concurrent control. • A completion transition fires when activity of source state is complete. – A composite concurrent state is complete when each substate is complete – each of them reached its final state. • So when each concurrent substate is completed then only merge transition is going to be fires. © RKU 2014 Prepared By Ashwin Raiyani
- Slides: 31