state machine

A model in which something is always in exactly one named state, such as idle, loading, success or error, and only defined events move it to another.

In more detail

Writing the allowed transitions explicitly rules out impossible combinations, such as loading and error at the same time, that separate true-or-false flags allow. A dialog, for example, is closed, opening, open or closing. User interfaces, workflows and network protocols are commonly modelled this way.

Examples

In AWS: A defined set of steps and transitions that coordinates a multi-step process, as AWS Step Functions does for AWS services.
In the browser: The HTML tokenizer is a state machine, and so is the service worker lifecycle, which moves from installing to installed to activated. Modelling behaviour this way makes it predictable: you can list every state and every allowed transition.
A circuit breaker moves between Closed, Open and Half-Open.

Related terms

Taught in

References

Certification courses