3 ms·
The part that specifies "which transitions are possible and which are not" (more precisely: which state results from a given state and input) -- known as the st
by davidrupp 4y ago
The part that specifies "which transitions are possible and which are not" (more precisely: which state results from a given state and input) -- known as the state-transition function [1] -- is a necessary component of the state machine definition. If you don't have that, you don't have a state machine in code; you just have a bunch of functions.
[1] https://en.wikipedia.org/wiki/Finite-state_machine#Mathematical_model https://en.wikipedia.org/wiki/Finite-state_machine#Mathemati...
- w4rh4wk5 4y agoMaybe necessary to define one by the book, but not to put one into code. I've seen enough state machines in the wild that are just a dispatcher with a bunch of functions mutating a single state variable. Whether we call these contraptions state machines or not is just quibbling. As others have pointed out, there are better ways to implement them; yet, I rarely come across those.