← Graph

Split Active Record into write and read objects

takeaway 3 connections

Practical refactoring: turn each Active Record model into two objects. The write object contains only the business decisions (validations, state transitions, publishing events) and has no Active Record dependency or readers. The read object remains an Active Record class used for displaying data, including associations like has_many :comments. They communicate via events. Immediately cuts model size by roughly 80%.

type
recommendation
takeaway Split Active Record into write and read objects
about
Active Record concept
Addresses the problem of bloated Active Record models.
takeaway Split Active Record into write and read objects
about
Direct formulation of the read-write split pattern.
takeaway Split Active Record into write and read objects
from_talk
Refactoring recipe presented in the talk.

Provenance

Read by
4 extractions