Convention over Configuration

I’ve just started reading Dave Thomas’ Agile Web Development With Rails and what strikes me as my favourite point about Ruby on Rails is the viewpoint of "Convention over Configuration".

This idea is nothing new, but I’m glad to see that it’s being done for the web. I used a 4GL mainframe tool in 1986 called Application Master that used a lot of conventions. You could tell a form to do an update, and if the screen names matched the database names, it would use them. You could, however, override convention and state the contents of all variables.

Here’s why I prefer convention:-

  • Comprehension. The less unnecessary code there is, the less there is to understand. Why write dozens of lines of code/XML to move variables to/from the screen, when you can have a simple convention, and your framework takes care of it.
  • Reliable code. The simpler that code is, and the closer it is to the business requirements, the more reliable it will be. One of the commonest problems I’ve seen is with omitted error checking or validation. One of my favourite things about working with Application Master was that there was a default behaviour with an error - rollback the transaction and redisplay the screen with an error message (the error message was also defaulted by convention). The only way that such an error would get through was if you told it that you wanted to override it.
  • Speed. Less code means less time writing code.
  • Prototyping/interative development. If you can say to a language "Here’s a table, build a form", you’ve got something to show, something for users to try. There is often a gap between user expectations and deliverables. The faster you get to showing something, and cycling around the requirements, the better.

—–

Discussion Area - Leave a Comment