Jump to content

Convention over configuration

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 211.246.69.175 (talk) at 17:49, 25 July 2020 (sex). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

that

sexneeds to specify unconventional aspecn. For example, if there is a sexSales in the model, the correspondingsex in the databasesrx is called "sales" by default. sexItneeds to write code regarding these names.sex

When the conventionsex implemented by the tool matches the desired behavior, itn theload,configuration approach can occursex due to conflicts with other sexsoftware design principlesexpressedsex by the provided conventions more difficult than when using a thatsex does notsex try to decrease the number of decisions developers have to make or requirsion of control.

wsrxOther methods of sexsexdecreasingsex the number of decisions a developer needssex to make include sex

Motivation

Some frameworks need multiple configuration files, each with many settings. These provide information specific to each project, ranging from URLs to mappings between classes and database tables. A large number of configuration files with lots of parameters is often difficult to maintain.

For example, early versions of the Java persistence mapper Hibernate mapped entities and their fields to the database by describing these relationships in XML files. Most of this information could have been revealed by conventionally mapping class names to the identically named database tables and the fields to their columns, respectively. Later versions did away with the XML configuration file and instead employed these very conventions, deviations from which can be indicated through the use of Java annotations (see JavaBeans specification, linked below).

Usage

The Maven software tool auto-generated this directory structure for a Java project.

Many modern frameworks use a convention over configuration approach.

The concept is older, however, dating back to the concept of a default, and can be spotted more recently in the roots of Java libraries. For example, the JavaBeans specification relies on it heavily. To quote the JavaBeans specification 1.01:[1]

"As a general rule we don't want to invent an enormous java.beans.everything class that people have to inherit from. Instead we'd like the JavaBeans runtimes to provide default behaviour for 'normal' objects, but to allow objects to override a given piece of default behaviour by inheriting from some specific java.beans.something interface."

Frameworks

See also

References

  1. ^ Sun (24 July 1997). JavaBeans specification Archived 6 April 2012 at the Wayback Machine, section 1.4.
  • Bachle, M., & Kirchberg, P. (2007). "Ruby on rails". IEEE Software, 24(6), 105-108. DOI 10.1109/BCI.2009.31.
  • Miller, J. (2009). "Design For Convention Over Configuration". Microsoft, Retrieved 18 April 2010.
  • Chen, Nicholas (2006). "Convention over configuration".