Speaker Deck

Introduction to Statemachines

by Bodo Tasche

Published January 8, 2015 in Programming

Rails has this nice little feature called Enums. The introduction example is something like this:

```
class Conversation < ActiveRecord::Base
enum status: [ :active, :archived ]
end
```

http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html

And I think this is dangerous. States should be dealed with in a state machine. Why you ask? Because state changes usually have conditions attached to them. Only archive if ... . If you want to model something like that with enums, you end up with a horrible version of a state machine.

Other Presentations by this Speaker

Thumb_slide_0

manpages

Jan 5, 2017 by Bodo Tasche

Thumb_slide_0

Tickety Tick

Oct 30, 2016 by Bodo Tasche

Thumb_slide_0

InfluxDB

Mar 3, 2016 by Bodo Tasche