Ensure you know the state of an instance.
Posted by jpluimers on 2015/11/24
A while ago, I came across a class having (among other members) two methods named like this:
- Start
- Stop
Within one of the other members of the class, I had to (temporarily) Stop processing, then Start it again.
But I couldn’t, as neither Start, nor Stop would make a record of the state it left the instance in.
Always ensure you know the state of an instance.
So I added the state, and tests to ensure a Stop/Start change was indeed not breaking things.
–jeroen






Sir Rufo said
If you need a more complex state handling you can use a statemachine https://github.com/SirRufo/stateless