90 likes | 101 Views
Learn about state machines and statecharts, their role in object-oriented design, and their use in modeling and testing multi-threaded programs. Explore the concepts of state actions, conditional state transitions, and nested states. Discover how to build effective models for fault finding and system behavior analysis.
E N D
Lecture 4 • Model checking/OBDDs • Design by contract • OCL: Object constraint language for pre and post conditions, invariants etc. • Testing multi-threaded programs • Testing state machines and statecharts
Chapter 19: State machines and statecharts • Widely used: graphical user interfaces, networking protocols. Important role in object-oriented design: some objects contain own state machine or state chart. Also useful for multi-object coordination (traversal state).
State machine or statechart • Two purposes • model • describes a portion of the system • implementation framework • provides skeleton for implementation
State machines • May grow large and cumbersome • Therefore, David Harel invented statecharts
Statecharts • State actions • on entry • on exit • do (called activity) • Example • on entry: notify repair center • on exit: log repair • do: flash service light
Statecharts • Conditional state transitions • Nested states: very useful. Allow to treat individual state as a state machine. Allow for clear boundaries between parts of the graph
State machine: Statechart sometimes exponentially smaller Decision tree: BDD (binary decision diag.) sometimes exponentially smaller Concise artifacts: a comparison
Start (H) Ready Warmup ok Is_warm Quality_ Check stop start on Copying Alternate_Start Backup_ Check_ Quality Backup_ Warmup Is_warm fault Error Low_resolution
When and how to build models • If a subsystem has a behavior that could be described with a state model but does not have one, create it. Helps with fault finding.