3 ms·
State machines are wonderful in general. I'm sure most people were taught it, but somehow it always seems more complicated than just to code some if-statements.
by guitarbill 9y ago
State machines are wonderful in general. I'm sure most people were taught it, but somehow it always seems more complicated than just to code some if-statements... until you have some spaghetti
logic with many transitions which is magically made maintainable and less buggy by refactoring it into a state machine.
That's how state machines first clicked for me, and it blew my mind. And this keeps happening, when somebody mentions it in code review, somebody's mind is usually blown.
So the more people read about this "boring" subject the better. Although the (non)deterministic finite automata (DFA/NFA) regex engines are a super interesting read IMO: https://swtch.com/~rsc/regexp/regexp1.html https://swtch.com/~rsc/regexp/regexp1.html