News for hackers. Stuff that matters.
Re:State Machines and the Strange Case of Mutating API by xaedes on Monday December 24, 2018 @05:14AM (#18751406)
> What options do we have to support such mutating API at the moment?

What is wrong with implementing the states with polymorphic classes providing the API or an interface to it?

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.

Re:State Machines and the Strange Case of Mutating API by rahulmehta95 on Monday December 24, 2018 @06:52PM (#18754959)
I was thinking that using Visitors would be a solution, which is a form of implementing a polymorphic API.
Re:State Machines and the Strange Case of Mutating API by rumcajz on Monday December 24, 2018 @05:35AM (#18751490)
Can you give an example?
Re:State Machines and the Strange Case of Mutating API by sovande on Monday December 24, 2018 @04:18PM (#18754315)