Remix.run Logo
nurettin 9 hours ago

State machines don't have syntax for "transition here when event is encountered no matter what state you are in" so the whole diagram becomes a spaghetti mess if you have a lot of those escape hatches.

lelanthran 2 hours ago | parent | next [-]

> State machines don't have syntax for "transition here when event is encountered no matter what state you are in" so the whole diagram becomes a spaghetti mess if you have a lot of those escape hatches.

I place a note at the top of my diagrams stating what the default state would be on receipt of an unexpected event. There is no such thing as "event silently gets swallowed because no transition exists", because, in implementation, the state machine `switch` statement always has a `default` clause which triggers all the alarm bells.

Works very well in practice; I used to write hard real-time munitions control software for blowing shit up. Never had a problem.

rramadass an hour ago | parent [-]

> hard real-time munitions control software for blowing shit up. Never had a problem.

Ha, Ha, Ha! The juxtaposition of these two phrases is really funny. I would like to apply for a position on the Testing team :-)

quietbritishjim 5 hours ago | parent | prev | next [-]

State machines don't have a native syntax in C++ at all, so you can structure them however you want. It's easy to structure a state machine, if needed, so that all (or some) states can handle the same event in the same way.

liontwist 3 hours ago | parent | prev | next [-]

goto is exactly this feature.

a_t48 9 hours ago | parent | prev [-]

I believe HSMs can model this, but don't quote me. :)

nurettin 8 hours ago | parent [-]

Yes, of course in theory nested state machines should be able to model this. I feel like adding more complexity and bending the rules is a bit of a concession.

jeffreygoesto 5 hours ago | parent [-]

Back in the days we implemented HSM helper classes in about 500 LoC and generated them from Enterprise Architect. No need to write a GUI yourself, but better to have a visual for documentation and review. Worked very well until we replaced EA with docs-as-code, now I miss that there is no nice simulator and Modeler for that workflow.