The basic principle:
State machines are often used to solve certain types of control-oriented problems, in which the control flow can be depicted as a movement through a set of different states. There are several different definitions and practical descriptions of a state machine; at a theoretical level, it is like an automaton that responds to a specific stimulus by changing its state. To give a specific, common expression, it can be considered, for example, as an automaton that reacts to the input string by moving through a set of states. If the desired state is reached, the input string becomes equivalent to the common expression.
Within control software, it is common to take the finite and deterministic nature of the state machine as the basis of its computational model. This fundamentally means that the number of possible states or combinations of states is finite, and that the state machine can only have one state at any given time. We will see later that the one-state-at-a-time rule can be relaxed, but the relevant aspect is that the state of the flow is a deterministic property.