menu

Statecharts

Statecharts are a precise, visual way of modeling the behaviour of complex reactive systems. They describe how things work, and can help you get your code doing exactly what you want.

Channels
Team

State Explosion

July 1, 2018 at 10:14am

I put the finishing touches on the page on State Explosion just now. Lots of hand-drawn images. To pre-empt the question on what I use to draw the statecharts, I use BoxySVG, which works well with my Chromebook!

https://statecharts.github.io/state-machine-state-explosion.html

Give it a read and feel free to use it if you ever need to explain the state explosion problem of state machines!

And as always, feedback is very welcome.


July 1, 2018 at 3:51pm

Maybe this is just because I’m reading on an iPad but in the diagrams, I don’t see any dashed lines between the parallel states

like-fill
1
  • reply
  • like

(The content is great, by the way!)

like-fill
1
  • reply
  • like

Thanks for mentioning the missing dashes. I used the wrong type of line for those dashes (or they were maybe a tad too thin).

  • reply
  • like

Fixed the diagrams! :tada:

  • reply
  • like

Perfect!

like-fill
1
  • reply
  • like

This is awesome, thanks!

like-fill
1
  • reply
  • like

July 2, 2018 at 4:01am

Looks great! Don't know if this is worth putting in the docs but another subtle advantage of hierarchies I've found is that they can help model 'AnyState'. Some state machine implementations like Unity's Mechanim and SwiftState have this extra concept. In the hierarchies diagram instead of having an event u1 from 'Valid' -> 'Unchanged' and another event u2 from 'Invalid' to 'Unchanged' there's just one u event from the child state chart to the parent. Basically, "if I am in any state in Changed and the event u happens, transition to Unchanged". It's a small distinction but if you are coming from other state machine impls and wondering how to model 'AnyState' with state charts, hierarchies can help.

  • reply
  • like

Thanks. I think I'll try to add this into the compound-state glossary entry.

  • reply
  • like

> Some statechart systems have a concept of "Any State" — one that is always active. Unity's Animation State Machines (where it's called "Any State") and SwiftState (where `nil` denotes the any state) are a couple of examples. The transitions defined for the "Any State" will always_ be in play. A compound state can play the same role as the Any State, by defining a single top level state to hold those types of transitions.

like-fill
1
  • reply
  • like

↑ Just adding that.

  • reply
  • like

July 2, 2018 at 4:55pm

looks good!

like-fill
1
  • reply
  • like