Articles

DCI and decoupling business logic from ruby on rails

By: Lancelot Carlson

Every so often the rails community adopts new best practices and patterns because someone figured out a better way to architect their applications. One great example was when everyone was urged to push the logic out of controllers and move it into models. This solved a lot of issues for most applications. Now we’re able easily isolate and test away the logic on the model layer instead of the hard to isolate controller layer.

Pushing the logic to the models created a nasty side effect however. Our models became completely bloated and hard to maintain. They contained logic that we tried to abstract away into model classes or new modules inside of the lib directory with one-off abstractions with no clear home. I’m sure some of us already knew there was something wrong, but perhaps it was only a gut feeling because no one piped up! It wasn’t until I saw Uncle Bob’s keynote speach at Ruby Midwest 2011 that I realized there was a huge flaw in the status quo of rails development.

Read the rest here: http://lancecarlson.github.com/2012/05/15/dci-and-decoupling-business-logic-from-ruby-on-rails.html