State Machine Design Articles
I’ve always been fond of state machines. I don’t know why but perhaps it has to do with the fact that they have a visual representation that makes it easy to understand the sequence of operations. Granted, I’m talking about well thought out state machines. I have seen people abuse the state chart tool to get spaghetti code from an ugly state diagram.
For programmable logic design they are great but I don’t get to use them that often in software. Most of the software projects I work on are already designed by the time they get to my hands and I can’t make architecture changes. Still, I like to read about them and one good article I found some time ago is here.
In it the author describes designing UML State Machines. He starts out by describing some errors that were found in a simple Visual Basic calculator program. Errors that could be prevented by using state machines instead of relying on the traditional method of using if statements. Not that there’s anything bad about using if conditions but we’ve all seen nested code that was almost impossible to read because it was so convoluted.
So, yes, state machines have more overhead and they are probably not the solution to all problems but they make nice alternatives to lengthy, nested conditionals. Food for thought.


