News for hackers. Stuff that matters.
Re:State Machines and the Strange Case of Mutating API by geezerjay on Tuesday December 25, 2018 @04:11AM (#18756680)
> What is wrong with implementing the states with polymorphic classes providing the API or an interface to it?

Yeah that's pretty much the basic approach to this problem: use a strategy pattern in all states of the state machine, and just provide definitions for each method in the state that the method makes sense.

That's pretty much how HTTP-based protocols are implemented when status codes drive a state machine.

I wonder why the author decided to ignore the most basic and simple solutions to a frequent problem in favour of a convoluted solution that doesn't add anything and is harder to debug.

There are no comments on this comment yet.