Chapter 29 State Machine Diagrams CS 6359 Fall

  • Slides: 11
Download presentation
Chapter 29 State Machine Diagrams CS 6359 Fall 2011 John Cole 1

Chapter 29 State Machine Diagrams CS 6359 Fall 2011 John Cole 1

State Machine Diagrams • They show a dynamic view, the interactions between states of

State Machine Diagrams • They show a dynamic view, the interactions between states of an object and reaction to events. CS 6359 Fall 2012 John Cole 2

Event • A significant or noteworthy occurrence – A telephone is taken off-hook –

Event • A significant or noteworthy occurrence – A telephone is taken off-hook – A key is pressed on a keyboard – A door is opened – A quarter is put into a vending machine CS 6359 Fall 2011 John Cole 3

Transition • Relationship between two states that indicates that when an event occurs, the

Transition • Relationship between two states that indicates that when an event occurs, the object moves from the prior state to the subsequent state. • When off-hook occurs, transition from Idle to Active state CS 6359 Fall 2011 John Cole 4

Applying the Diagrams • If an object always responds the same way to an

Applying the Diagrams • If an object always responds the same way to an event, it is state-independent or modeless. • State-dependent objects react differently to messages depending upon their state. • A telephone is very state-dependent. Its response to pushing buttons depends whether it is on-hook or off-hook and whethere is an ongoing call or not. CS 6359 Fall 2011 John Cole 5

When to Use • Consider state machines and diagrams for complex, state-dependent objects, not

When to Use • Consider state machines and diagrams for complex, state-dependent objects, not for state-independent objects. • Business information systems seldom have much state-dependent behavior (although the UI may have some) • Process control, device control, and telecom have many state-dependent objects CS 6359 Fall 2011 John Cole 6

Modeling State-Dependent Objects • State machines applied in 2 ways: – Model the behavior

Modeling State-Dependent Objects • State machines applied in 2 ways: – Model the behavior of a complex reactive object in response to events – Model legal sequences of operations such as protocol or language specifications. A formal grammar is a kind of state machine CS 6359 Fall 2011 John Cole 7

Complex Reactive Objects • Physical devices • Transactions between related business objects. How does

Complex Reactive Objects • Physical devices • Transactions between related business objects. How does sale, order or payment react to an event? • Role mutators are objects that change roles based upon events. Person changes from civilian to veteran. City changes from destination to origin. CS 6359 Fall 2011 John Cole 8

Protocols • TCP can be understood with a state machine diagram • UI page/window

Protocols • TCP can be understood with a state machine diagram • UI page/window flow or navigation • UI flow controllers or sessions • Use case system operations • Individual UI event handling CS 6359 Fall 2011 John Cole 9

Transition Actions and Guards • Transition cause an action. This may be invocation of

Transition Actions and Guards • Transition cause an action. This may be invocation of a method. Transition may also have a test and it occurs only if the test passes. CS 6359 Fall 2011 John Cole 10

Nested States • States can have substates which inherit the transitions of the superstate.

Nested States • States can have substates which inherit the transitions of the superstate. CS 6359 Fall 2011 John Cole 11