3 ms·
A colleague raised the point that state machines (or their richer variations) work best in models with low cohesion. Anybody here have some thoughts/experience
by braythwayt 9y ago
A colleague raised the point that state machines (or their richer variations) work best in models with low cohesion.
Anybody here have some thoughts/experience with this point of view?
- tonyarkles 9y agoMy (admittedly limited) experience had some high-cohesion models and it worked ok, with the caveat that they often didn't change independently. It was basically one FSM for a cluster of high-cohesion objects, and the events would mutate some subset. I agree with your colleague somewhat. If you have a system where every domain object is inextricably linked to every other domain object, then you're going to have a state explosion trying to capture the states and transitions. My gut reaction looking at a system like that is to start decomposing it, looking for accidental coupling that doesn't need to be there.
- ahartmetz 9y agoI have related experience with QStateMachine versus hand-written (state variable(s) + switch + some freeform manipulation): if your state machine is "pure", using the framework is nice. If your state machine needs certain interesting transitions such as undo which don't fit in, you may be better off writing it yourself. If it fits at all, a funny state machine is better than no concept for your state variables. You still get most of the benefits. I guess domain-specific transitions like undo and cohesion mean similar things to state machines: requirements that don't cleanly fit into conventional state machine models.