Loading...

Mike Gehard

ActiveSupport::Concern vs Plain Old Ruby Objects for Encapsulating Business Logic

Mike loves to take the best bits from all the languages he written in production (currently Ruby, Scala, Kotlin, Go, PHP, JavaScript, Java, C++) and apply them to any development problem he’s solving. He firmly believes that languages are a tool…and sometimes one tool is better for a job than another.

ActiveSupport::Concern vs Plain Old Ruby Objects for Encapsulating Business Logic

ActiveSupport::Concern is a mechanism introduced in Rails 4 that simplifies the creation and inclusion of Ruby mixins. The goal is to provide a mechanism to share cross cutting concerns, both data access and domain logic, across multiple Rails models. In theory, this sounds like a great way to organize our Rails codebases. In practice, especially in larger Rails codebases, this abstraction mechanism creates more maintenance problems than it solves.
This talk will use a “real life” example to demonstrate the use of ActiveSupport::Concern and then introduce another mechanism for encapsulating the same functionality, the plain old Ruby object. It will compare and contrast the two approaches and give attendees enough information to make their own decisions about which approach is best for their codebases.