From 6:00 PM CST Friday, Feb 15th - 2:00 AM CST Sunday, Feb 17th, ni.com will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Table Of Contents

When to Use a State Machine

Last Modified: September 27, 2017

A state machine consists of discrete segments of code, otherwise known as states, that execute one at a time with a transition between each execution.

The following tasks are examples of situations for which state machines are well suited:

  • Responding to user interface interactions where the user's action determines which state executes.
  • Process testing where each state carries out a step of the process.
  • Breaking down difficult to manage applications into smaller, easily maintainable chunks of code.

However, a state machine is not well suited for every programming situation. If your program needs to run parallel processes, you may want to choose a different design pattern.


Recently Viewed Topics