Hacker News new | ask | show | jobs
by knsv 1094 days ago
The problem with state machines that I run into often when using them, is "multi-dimensional" states.

When managing to get that right they are great, otherwise you get loads of edges...

2 comments

I'm not sure what you mean by "multi-dimensional" states. Is it something that statecharts [1] can help with?

[1] https://statecharts.dev/

UML Statecharts are Harel Statecharts, which are hierarchical state machines. Described here:

Statecharts - A visual formalism for complex systems. David Harel. 1987

https://archive.org/details/7.-statecharts

Looks like you can also freely download the paper from here: https://www.sciencedirect.com/science/article/pii/0167642387...

The cross product of multiple state machines, I expect. If you try and use a single state diagram to encode the product of states, everything multiplies.
That’s where statecharts can help.
Not sure what you mean by multidimensional states?
The car can be in drive, neutral, or reverse, the light can be red, green, yellow, or broken, the seatbelt can be off or on. That's 24 states.
Ah, ok. That's kind of what I meant by upfront design, though. Yeah, mapping this out is gonna suck, but it's better than having it hidden in a bunch of ifs.