4 ms·
I find I got the same issues even with state machines. If the problem is complex, you have to consider every edge case with or without state machines. The essen
by tlarkworthy 3y ago
I find I got the same issues even with state machines. If the problem is complex, you have to consider every edge case with or without state machines. The essential complexity is the same.
- nailer 3y agoI think the idea is the state machine makes you consider every possibility. For example, what happens when an enemy gets shot when they are in the ‘dead’ state?
- tlarkworthy 3y agoThey still go into trap states. If you try to remove default transitions your source code complexity explodes.
- nailer 3y agoHrm. I used to not understand what state machines were (I don't have a CS degree) and mistakenly think they were adding complexity. I use them regularly now. I make my own, so they don't have default transitions to remove (beyond throwing 'not implemented' errors when I haven't built a particular transition yet), and I'd still say they're less complex than managing state without them. Thinking about 'remove default transitions' - are you talking about using a particular state machine library? My default model is writing them. It's kind of like using a feature flag library when a hashtable with features for keys and boolean values will do. OK maybe use a library if the library adds realtime control etc, but not for the basic concept of flags - likewise a state variable and a single transition function work very well for state machines.
- tlarkworthy 3y agoThe idiomatic calculator interface is actually very hard to implement without bugs https://mitadmissions.org/blogs/entry/designing-a-calculator-with-fsm-logic1/ https://mitadmissions.org/blogs/entry/designing-a-calculator... FSM don't help with the bugs. You need analysis on top to actually make a dent in the bug count