33 ms·
Why? You can easily emulate a state machine with a while loop, a switch case and one more level of if-branches. Abstracting those in a framework doesn't make it
by m_mueller 5y ago
Why? You can easily emulate a state machine with a while loop, a switch case and one more level of if-branches. Abstracting those in a framework doesn't make it unstructured IMO.
- lmm 5y ago> You can easily emulate a state machine with a while loop, a switch case and one more level of if-branches. You can easily emulate GOTO much the same way.
- m_mueller 5y agoobviously, as long as the language is turing complete, but you just converted an unstructured program to a structured one.
- maskros 5y agoAnd gained nothing except more verbose syntax. The goto spaghetti is still spaghetti whether you use "goto" or "switch".
- m_mueller 5y agoDisagree. You eliminate backward gotos except for the while loop, which is much more clearly communicating the way to extend the code (by adding more states or state transitions) to the next person taking over. I‘m not categorically against goto in certain contexts (like C based systems programming), but IMO backwards jumps with goto need to be eliminated.
- lmm 5y agoTo the same extent, and in the same way, as you did when you converted a state machine the same way? I still don't get what distinction you're drawing between state machine style and GOTO style.