Convention over Configuration
From Wikipedia, the free encyclopedia
This article does not cite any references or sources. (April 2008) Please help improve this article by adding citations to reliable sources. Unverifiable material may be challenged and removed. |
Convention over Configuration is a software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility.
The phrase essentially means a developer only needs to specify unconventional aspects of the application. For example, if there's a class Sale in the model, the corresponding table in the database is called sales by default. It is only if one deviates from this convention, such as calling the table "products_sold", that one needs to write code regarding these names.
When the convention implemented by the tool you are using matches your desired behavior, you enjoy the benefits without having to write configuration files. When your desired behavior deviates from the implemented convention, then you configure your desired behavior.
This more configuration free approach to programming allows the programmer to work at a higher level of abstraction without actually having to create a layer of abstraction.
[edit] Motivation
Traditionally, frameworks have needed multiple configuration files, each with many settings. These provide information specific to each project, ranging from URLs to mappings between classes and database tables. With the complexity of an application the size and number of those files grows as well.
The well known persistence mapper Hibernate for instance maps entities and its fields to the database by describing these relationships in XML files. Most of this information could actually be revealed by conventionally mapping class names to the identically named database table and the fields to its columns, respectively. This would be a convention established by the Hibernate developers and promulgated to their users, i.e. the developers who are using the framework. In order to not be restricted to the naming convention of a framework you can always override the convention by explicitly configuring these exceptions.
[edit] Usages
The framework most strongly associated with the paradigm is Ruby on Rails, which popularized the concept. Other frameworks, like Spring, Castle MonoRail, JUnit and JBoss Seam take similar approaches.