Re:Facts about State Machines
by ww520 on Friday September 30, 2022 @07:24PM
(#33042003)
There're different ways to implement a state machine, table-driven, object-driven, function pointer driven, callback based, etc. If you just want a simple and hard coded sate machine, nothing beats switch statements. You can do something like the following.
That's it. It's simple to understand and it's clear what the legal transitions are from each state based on the input. You can attach actions and data update on each state transition to do something useful.
[ Parent
| on HN ]
There are no comments on this comment yet.