3 ms·
Statecharts are in fact descriptions of state machines. They are just not ordinary state machine diagrams based on a single, scalar state variable. The state e
by kazinator 6y ago
Statecharts are in fact descriptions of state machines. They are just not ordinary state machine diagrams based on a single, scalar state variable.
The state expressed in Statechart could be turned into a single variable, and the chart could be refactored into a flat state transition diagram.
But that diagram would potentially be huge compared to the state chart description.
The state chart condenses that description by avoiding the duplication of some sub-state-machine for every change of some variable which is irrelevant to it.
E.g. suppose a device has two master modes of operation, A and B, in which it responds to inputs in totally different ways. Suppose that mode A and B retain their internal state when the mode switch takes place.
If we don't use a hierarchical state chart, we end up having to represent what happens when a certain input arrives in a state under mode B, for every possible state in mode A which is not actually in effect and irrelevant. Basically, we have to deal with the product state space, in which the explosion leads to numerous identical combinations.
- emmanueloga_ 6y agoState machines as formally defined are incredibly low level, lacking even things like guards (predicated transitioning) and transition actions. So Statecharts adds a lot on top of them, but yeah, the foundation is FSMs.