Summary
Favoring convention over configuration is a technique popularized by Ruby on Rails, but it can be used in any language or framework. To what extent does the productivity advantage that can be gained from this technique hinge on whether the project is a green field design?
Advertisement
In You Shouldn't Compare Rails to Java EE 5, or JavaScript/Ruby to the Java Language, Adam Bien suggests that the technique of favoring convention over configuration is most suited to green field designs—brand new designs that have no requirements to fit with legacy code and infrastructure. The technique of "favoring convention over configuration" was recently popularized by Ruby on Rails, but can be employed in any language in any framework. The technique is given credit as one of the main ways Rails helps make programmers more productive at building web applications. Bien states that in the projects he's worked on, often the database already existed, and therefore, "The 'convention over configuration' advantage was gone." In addition, Bien states that "in the last 11 years, I had only few 'green field' projects."
To what extent do you believe that convention over configuration is most helpful for green field designs? How often have you been able to work on a green field design?
Convention vs. configuration is misleading. A library or framework should have reasonable defaults that let you use it 'out of the box'. It should be configurable for special cases but configuration should be an exception, not the norm. A library eg. that requires the user to write heaps of XML configuration files to perform standard usage clearly misses the point.
It's true that convention over configuration doesn't help much if you don't follow the conventions (because you're working with an existing db for example). On the other hand, there aren't many projects where you don't create new things at all. You can use convention over configuration if you have control over these new things.
An example of convention over configuration:
def generate_pi(decimals = 10)
# compute pi
end
compute_pi() => 3.14...
compute_pi(2) => 3.1
The convention is that you compute pi upto 10 decimals. This will be enough for most uses, but you can override it if you want.
Such small-scale convention over configuration is also valuable in existing projects.