Tuesday, February 17, 2009

Convention Over Configuration

Convention Over Configuration refers to predefining conventions (for example a standard location where a file/directory is expected or following a naming schema for resources) for underlying frameworks/applications so that framework/application can work without having to specify these entries in configuration files. This enable end user of software to get going without lot of configuration, however a user/developer still has flexibility to configure in unconventional way.

Another term used is "Configuration by exception", configure when there is exception to rule(convention).

Example of these are plenty,

Build tool Maven expect source files to be in certain conventional location (like java classes reside in main\java\src ), however user can still specify other location for source code.

Hibernate Data mappings can work without specifying mapping files by following convention for Table names matching Class names.

Advantages:
-End user/developer can get going without too much configuration or too much boiler plate code(code that is repetitive and standard).
-Provides structure/discipline to a projects, certain things should be done using conventions, like source files should be named certain ways. Convention makes it easier for developer who is familiar with convention to jump into a project, as the project is organized in a familiar way. (On the flip side a developer who is new to framework, need to learn conventions!)


Disadvantages:
Underlying framework/application has to write code for convention and for configuration.
Convention have to be learned.