Bodo Tasche 🔭 wants to give this talk
Introduction to Statemachines
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.
So let's see how we would do this in a "more cleaner way" with state machines.
22 People like it
- Rin Raeuber
- Anton Volkov
- Joe Corcoran
- Jan Schulte
- rockaBe
- Davide Prati
- Matthias Viehweger
- fscrock
- Sergio Gil Pérez de la Manga
- Maciej Majewski
- lislis
- Tadas Sce
- David Boot
- Martin Frank
- Christoph Grabo
- Holger Frohloff
- Duilio Ruggiero
- Christoph Bünte
- Sebastian Ziebell
- Florian Ebeling
- Falk Köppe
- Roman M