"Business Logic in Ruby"
summary
A practical path from Smalltalk and Java habits into Rails shows concrete patterns for extracting business logic out of ActiveRecord: CQRS split into reader/writer models with events, event sourcing for the write model, and implementing workflows as state machines that can be tested and mutation‑tested with the provided GitHub repo. Experiments compare aggregate roots, polymorphic state objects, duck typing, and DCI via Module#extend and clone hack—the latter works but creates allocation and method‑dispatch costs. Recommendations: DDD, event sourcing, and grammar/property testing.
AI-written summary · about
chapters (8)
- 0:00Introduction and background
- 2:10Business logic in Ruby
- 7:42CQRS and splitting models
- 11:17Aggregate root pattern
- 14:47Polymorphic aggregates
- 20:06Data Context Interaction
- 27:57Conclusions and takeaways
- 32:32Q&A session
related talks
42mRoundtable: Where to Keep Business Logic in RoR Applications?
31mIf it bleeds, it leads
34mSimple and Elegant Rails Code with Functional Style
39mDown The Rabbit Hole: An Adventure in Legacy Code
31mThe History of Rails in 10 Blog Posts
32mruby best practice patterns
39mExploring Rails anti-patterns
01h 47mWorkshop - Applications First, Frameworks Second: Better Systems through Design
