Software Engineering 67528 Fall 2012 State Diagrams State















- Slides: 15
Software Engineering 67528 Fall 2012 State Diagrams
State diagrams • State diagrams model dynamic Aspects of a system • Two Ways of visualizing execution dynamics in a system – Flow of control from Activity to Activity(activity diagrams) – Emphasizing potential states of objects and transition among these States(State Diagrams) • UML Style based on David Harel Statecharts. See his IEEE Computer paper for OO design (original paper from 1984) http: //www. wisdom. weizmann. ac. il/~harel/SCANNED. PAPERS/OOStatecharts. pdf And a conference paper on statechart history here http: //www. wisdom. weizmann. ac. il/~harel/papers/Sta techarts. History. pdf
State Diagrams • State machine Definition – Behavior that specifies a sequence of states an object goes through during its lifetime in response to events – Dynamic aspects of a system are modeled. – Specifying lifetime of a class instance subsystem or entire system – Goals: efficient, simple, adaptable, understandable
State Diagrams • State – Condition or situation during an object’s lifetime which satisfies some condition • Event – an occurrence that can trigger a transition from one state to another in an object • Transition – relationship between two states indicating that the object in the first state responds to an event by transitioning to another state • Activity – Non atomic execution in a state machine • Action – computation that results in value return or change of state
State Diagrams • Context – relates to lifetime of object • States – situation in the object context that satisfies some condition, performs an activity or waits for an event – Parts of a state • • • Name Entry/Exit Effects Internal Transitions Substates – nesting Deferred Events – events whose handling are deferred
State Diagrams • Initial State • Final State – Shut Down, Destruction
State Diagrams • Transitions – Relationship between states indicating that object in first state will perform certain actions and enter second state upon event and/or conditions – Change of state termed as transition is said to fire – 5 parts to a transition • Source • Event Trigger • Guard Condition – condition to evaluate upon event that can trigger transaction • Effect – an action that may act on the owner of the machine • Target State
State Diagrams • Advanced States and Transitions – Entry/Exit effects – Internal Transitions – Do. Activity – Activity to do without event handling – Deferred – respond to event with a timelag – Fork and join – decision point – Submachines
State Diagrams • General Examples – Forward Engineering - Code can be created from these diagrams. The actions of the class. Class Diagrams generate the structure of the class. – Reverse Engineering – theoretically possible, these tools have no capacity for abstraction and useful output not always produced. – Animation of model using debugging techniques
State Machines • How do we know that a state diagram is useful – Easy to follow easier than code(graphical) – One aspect of system dynamic – Include only what needed for that dynamic – Detail consistent with abstraction – Use Submachines think of them like you do functions(if you still think procedurally) or methods
State Diagrams
State Diagrams
State Diagrams • Telephone Connection
State Diagrams • Fork and join transition
State Diagrams • Events – External Pressing a Button, interrupt from sensor – Internal inside the objects that are alive in the system • Signal – Sent Asynchronously from one object to another – Message type