News for hackers. Stuff that matters.
Re:Developers should be force-fed state machines (2011) by stinos on Thursday April 20, 2023 @11:40AM (#35641784)
I'd guess the built up data structure data structure would be something like a dictionary that maps from the current state to a dictionary that maps from trigger conditions (or commands in the code above), to a struct that contains the new state, and optionally a transition action function pointer (or delegate, or whatever your language calls them).

That's about right yes. This particular thing was in C# in a fairly large desktop application, and the little extra memory needed for this or potential performance overhead of a dict wasn't a concern at all in the greater scheme of things.

There are no comments on this comment yet.