State Machine Diagrams Flashcards
(20 cards)
What is a state machine diagram?
A diagram showing how an object changes states (like ‘on/off’) in response to events.
What are the two main parts of a state machine?
- States (boxes) 2. Transitions (arrows between boxes).
What is a ‘state’?
A condition an object is in (e.g., ‘Idle’, ‘Processing’, ‘Error’).
What are the three special state activities?
entry/ (runs on entering), exit/ (runs on exiting), do/ (runs while in state).
What triggers a transition?
An event (e.g., button press, timeout) + optional guard condition.
What’s the difference between internal and external transitions?
Internal: Stay in same state (run actions). External: Move to new state (run exit/actions/entry).
What are the 4 event types?
- Signal (e.g., ‘mouseClick’) 2. Call (e.g., ‘register()’) 3. Time (‘after(5s)’) 4. Change (‘when(x>y)’).
What is a guard?
A condition in [brackets] that must be true for transition (e.g., ‘[balance>0]’).
What’s the initial state?
A black circle (●) showing where the machine starts. Not a real state.
What’s the final state?
A bullseye (⭘) where the machine ends. Object stays here forever.
What’s a terminate node?
A cross (✖) that deletes the object (unlike final state).
What does a decision node look like?
A diamond (◇) splitting paths based on guards (like ‘if/else’).
What are parallelization/synchronization nodes?
Solid bars (━) splitting/merging concurrent flows (like forks in activity diagrams).
How is time modeled?
With time events: ‘after(10min)’ (relative) or ‘when(time=12:00)’ (absolute).
What’s a ‘change event’?
Continuously checks a condition (e.g., ‘when(temperature>100)’).
What’s an example state machine?
Traffic light: Red → (timer) → Green → (timer) → Yellow → Red.
Why use state machines?
To clearly show complex object behavior (e.g., login: ‘Entering → Validating → Success/Fail’).
What’s a pseudostate?
A temporary control point (e.g., initial state, decision node).
How to show actions during transition?
On transition arrow: ‘event [guard] / action()’.
What’s a ‘completion event’?
Automatic transition when state’s ‘do/’ activity finishes.