I’ve noticed that state machines get mentioned a little more often than they are explained. A state machine (sometimes finite state machine) is a model of states and transitions between those states. If we wanted to convert a year into a state machine of seasons we know the name of the states would be “spring,” “summer,” “autumn/fall,” and “winter,” and the transition between them would normally be “wait three months.”

It is a (rather inefficient) state machine with an infinite number of states, similar though they are.

Talking of user content in a state, there is a small adjustment that we can make to the simple state machine code to make it a little more useful in general.

Related Articles