5 ms·
I've worked in the past with code bases that have what were called 'state machines' implemented with at best switch statements and at worse a lot of if's and el
by kejaed 6y ago
I've worked in the past with code bases that have what were called 'state machines' implemented with at best switch statements and at worse a lot of if's and else's and some state variables.
I've also worked with code bases with a formally defined state machine object/concept, with pre-defined states, events, and state transitions driven by events.
Question for the crowd: what would you call the non-state machine state machine in the first case?
- brentm 6y agoYou'd probably still call it a state machine if that is what it's doing. Maybe not well implemented but it also depends. State machines are tricky to get right.
- carapace 6y ago> what would you call the non-state machine state machine in the first case? Ad hoc state-machines? I don't think there's a formal name for them.
- kejaed 6y agoAd-hoc is a great term for this, thanks.
- zanecodes 6y agoI would call the former an implicit state machine, while the latter is an explicit state machine.
- kejaed 6y agoThis is perfect, thanks!
- vbtemp 6y agoState machines implemented in-line with code usually end up as a mess. It's best if they are factored out, and implemented as a DSL inside a true state machine engine running as a somewhat independent service or library.