3 ms·
I disagree. State machines are anti-modular: By clearly defining the transitions from one state to another and when outputs can occur I see state machines as m
by forgotAgain 15y ago
I disagree.
State machines are anti-modular: By clearly defining the transitions from one state to another and when outputs can occur I see state machines as making it easier to develop modular applications. I don't see how it inevitably leads to non-modular code.
State machines are anti-abstraction: If you're modeling a process then some things can't be abstracted. At some level you have to deal with real world situations.
State machine code is hard to read: That's a function of the effort made to make it easy to read. It's no different than any other situation.
In general I find state machine design to be helpful in literally controlling the state of an application. By limiting what an application does and when it can do it, via an easily understood mental model, it's a straight forward design technique.
- aristidb 15y ago> By clearly defining the transitions from one state to another and when outputs can occur I see state machines as making it easier to develop modular applications. I don't see how it inevitably leads to non-modular code. I have not seen a modular state machine yet. Perhaps it is possible, but it doesn't seem to be done very often. > If you're modeling a process then some things can't be abstracted. At some level you have to deal with real world situations. I don't think state machines are usually the most natural representation of a process. And very often, people use state machines to model things that don't really fit into that model. > That's a function of the effort made to make it easy to read. It's no different than any other situation. Perhaps I have only seen the bad apples.
- kreneskyp 15y agoThe problem is that many apps are looking at the wrong states when they design their machine. For instance I worked on an app someone had build in which states were based on a multi-page html form. When I added an android app allowing offline data collection, I then had to hack around the state machine. We couldn't just create a instance of the object with the final data, we had to write code that replicated the submissions of the html form.
- jbrechtel 15y agoThis echos my experiences exactly. I've found little value in state machines as a frequently used pattern. Abuses abound and I've also ran into the multi-page-html-form-as-a-state-machine anti-pattern. It's horrid and should not be done.