h3. What is an abstraction layer?
An example: *Every kind of _framework_ is an abstraction layer.* It saves you from working with concrete code by providing _higher-level_ methods and concepts. Ruby abstracts assembler, Rails abstracts working on HTTP-based applications, ActiveRecord abstracts SQL, and so on.
h3. What’s your problem?
The funny thing is, basically I agree (again!) with dhh and his followers: *I like abstraction layers*. To be precise, I especially like abstraction layers if
* they are *horizontal _layers_*, meaning they are *clearly separated modules* and not hard-wired in the core like @RJS@. @ActiveRecord@ in Rails 3 is a good example of a cleanly encapsulated abstraction layer.
* they are *_optional_*. Rails has opinionated the process of developing web apps for years (ORMs, “monolithic controller/view architecture”:http://nicksda.apotomo.de/2010/11/rails-misapprehensions-cells-dont-break-mvc/, “pseudo-REST”:http://nicksda.apotomo.de/2010/10/rails-misapprehensions-crud-is-not-rest/). People are used to it and want soft transitions (well, actually this is _not_ my very opinion, whatever).
* they are *vertical _layers_* in a sense of splitting one monolithic app into several manageable component applications. This is also an abstraction layer and completely ignored in Rails.
h3. Have more abstraction layers!
Rails is a web framework and does a pretty good job at it. It gives you PHP-like templating, a great ORM and the @FrontController@ pattern. Now this is Rails status quo.
*Abstraction layers must be separate gems* with adapter modules for Rails. Rails itself needs an architecture towards this, and Rails 3 already is a great step in this direction.
Abstraction layers should also try to be separate layers and not mix in stuff randomly into M, V, and C at once.
If you hard-wire “abstraction layers” into the core, *they are no _layers_ anymore*. This is my problem with the “current implementation of RESTful representations”:http://nicksda.apotomo.de/2011/04/rails-misapprehensions-the-hardest-thing-about-rest-is-working-with-representations/ in Rails. Another example where more work is needed is the view layer. The “cells gem helps having object-oriented views”:https://github.com/apotonick/cells by _abstracting_ stupid partials and helpers to view components.
h3. Too much abstraction means Java!
Don’t get me wrong here. *I do not evangelize useless abstraction.* That’s why I say “_Make it optional!_” If you have lot of JS, use “coffeescript”:http://jashkenas.github.com/coffee-script/. If you have RIA frontends or portals in Rails, use “Cells”:http://github.com/apotonick/cells or “Apotomo”:http://apotomo.de/. If your CSS is bloated, use “Compass”:http://compass-style.org/, and so on.
*But please keep the Rails core an _abstract_ core.*
Now, please stop the comment spamming on github and spam me instead.