As we delve further into requirement analysis, we will explore some modeling techniques that can be used to better understand system behavior. First on our list is the state machine diagram:
A state diagram is a directed graph where the nodes are states and the edges are transitions — occurrences of events.
Figure 8.1 Simple state machine diagram.
At any given point in time, the system or object is in a certain state. A state is a constraint or a situation in the life cycle of an object, in which a constraint holds, the object executes an activity or waits for an event.
States can trigger actions — an atomic execution — and complete without interruption. In total, there are four triggers for actions: On Entry, Do, On Event, On Exit.
Exactly one initial state is mandatory, while a final state is optional. The initial state represents the starting point of the entity's behavior, while the final state represents the end point of its behavior.
There can only be on initial state, but there can multiple final states. For example, consider a Tic-Tac-Toe game.
Figure 8.2 State diagram for a Tic-Tac-Toe game.