Terminator: Death to the (State) Machines

By Eumir Gaspar

Elevator Pitch

State machines are very helpful in managing state in objects and we have a lot of gems that do this. In most cases, these state machines grow from simple to utterly atrocious. This talk aims to help developers understand them and manage them easily. Also, this is not another state machine gem talk.

Description

State machines have helped us manage object states since forever. This day and age, most of them have risen against mankind and it is up to us to end their tyranny. This is for people considering state machines and how to manage them effectively - without losing your sanity or life in the process.

Imagine going back to the times where humans used (state) machines as tools. Now look at your current state machines that hold you within their grasp - those after transitions, callbacks, auto scopes and methods! It’s like observers all over again! It is time to rise against these machines and free our people! Rebel! Refactor!

Notes

My teams and I have used a bunch of state machine gems like aasm, state_machine etc. and while they all have their pros, a huge part of making them unmanageable is their implicit methods and callbacks. I aim to help people understand that these are no better than the dreaded observer pattern and tends to be very unwieldy and hard to maintain.

This talk is targeted to intermediate / advanced Ruby developers but can also benefit junior / beginner ones who understand the concept of state machines.