Table Of Contents

State Machine Design Pattern

Last Modified: January 12, 2018

You can use the state machine design pattern to implement decision making algorithms where a set of distinguishable states exists.

These states, or subdiagrams of code, carry out specific operations within a program. Only one state executes at a time while the machine is active.

After all of the code within a state executes, the state outputs a transition value and initiates a state transition. This transition advances the program from the finished state to the next state indicated by the transition value.

During a state transition, data from the completed state is sent to the upcoming state. Once the state machine executes its final state, data output by the machine becomes available for other parts of the program to use.

Recently Viewed Topics