Sat Nov 9 06:58:41 EST 2019
desinging state machine
I have been resisting this for a while, but it is becoming apparent
that state machines need to be designed from the perspective of
translating events into state updates.
When I write it down like that it seems completely obvious, but for
some reason I am still inclined to think of them in terms of blocking
Most machines that I encounter are protocol parsers. So let's write
it from that perspective.
The trick seems to be to write things down is such a way that the
"core loop", i.e. the part that takes individual tokens and assembles
a message is as simple as possible.
The odd thing is that once such a core machine is written, to then
translate it to blocking code form is usually trivial.