This looks silly, and there's been knock knock jokes, but it's actually hard to catch with a code review and it's not an uncommon kind of problem. A few years back there was a similar issue in OpenSSL (and not to knock OpenSSL either!) ...
We enumerate of every valid order of states. Then, by choosing an enumeration just once, we reduce every state transition to a simple one step forward.
-
-
Ah I think I got it. With your code being structured this way, you ensure that there is a single "entry point" to each state and that it comes from a correct previous state?
-
Yep! I think of it like a single entry point into a strong "chain" of states. Rather than each state deciding where to go next ... which has been more likely to go wrong.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.