relaxdiego

When it comes to implementing non-interactive processes, using state machines has been one of my go-to designs for the simple reason that it’s very good at preventing flow/action spaghetti and, therefore, makes for a maintainable codebase.

What’s even more awesome about it is that becuase the decision table (flow) is located in a built-in data structure, it’s very easy to graphically represent it using Graphviz! Here’s a sample of what that might look like:

I’ve used state machines succesfully from automating spot instance bidding in AWS, to automating my tennis court and campsite reservations. As I was working on Ansible modules, I kept thinking about whether state machines would also be a good fit.

Well, rather than keep wondering about it, I decided a few weeks back to prototype it instead. Here’s the pull request that details it all. Looking forward to some feedback there!

Found a bug in my post? Submit a ticket on GitHub!