News for hackers. Stuff that matters.
Re:Why developers should be force-fed state machines by nitrogen on Monday June 13, 2011 @04:11PM (#2650515)
In C it is possible to use functions to represent state. To cause a state change, you return a pointer to the function representing the next state. Each state function manages transitions away from that state. The main event loop repeatedly calls the current state function with any external input relevant to the system. There is also the giant switch block option, with the current state stored as an enum.

With a little discipline, I think it should be possible to represent state machines in a readable fashion in most popular programming languages.

There are no comments on this comment yet.