Discovering a world of resources
Over the past couple of months, my interest in HTTP, resources, and the effects of a CRUD-constrained approach to controllers have lead to a profound simplification in how I develop Rails applications.
I've been putting all of these thoughts to use in my work on Sunrise, the next application from 37signals, and its already proven a treasure trove of extractions.
As often is the case, these extractions see the light of day even before the originating application does. So at both RubyKaigi and RailsConf, I took the opportunity to explain where we are and the immediate future as I see it. Now that both those presentations have been delivered, the slides are available.
Interestingly enough, the most profound benefit I'm witnessing of this renaissance for HTTP has not been related to first-order glories of the protocol itself. But rather to the second-order impact it has on domain modeling. The birth of a new default assumption to design: "What if the whole world could be modeled under the constraints of CRUD?".
That's where the biggest and most satisfying payoff has lied for me personally. It's somewhat similar to the notion that test-driven development is less about tests and more about design. There are two examples in the slides to exemplify the effects of such a transformation.
I believe that's also what gave some people the chills at RailsConf. "Is DHH trying to to tighten the belts on the straight jacket of design once more?", seemed to be the worrying notion. Why yes, I am. But this time its an entirely voluntary committal. The brave new world of resources is accessible by choice, not mandate. And if you want to continue on with your life with a notion of HTTP as merely an inconsequential transfer protocol unworthy of your attention, you'll be more than free to do so.
But. If you choose to partake in the renaissance, be prepared to raise your game to a new level of delight. There's a rejuvenation awaiting you. One that'll simplify your controllers, bless your application with an almost-free REST API, and elevate your domain model even further away from the depths of anemic.
Can I get a hallelujah?
(Jim has a good walk-through of the specifics of the presentation that's worth reading while perusing the slides)