All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

What is Convention over Configuration (in the context of RoR and beyond)?

Post cover: What is Convention over Configuration (in the context of RoR and beyond)?
Table of contentsClick link to navigate to the desired location
This content has been automatically translated from Ukrainian.
Convention over Configuration (CoC) — is a principle that states that a system or framework already has default configurations, allowing the developer to avoid writing/creating settings independently. This significantly reduces the number of decisions that need to be made and decreases the time spent on configuration and development overall.
This approach first gained popularity thanks to the Ruby on Rails framework. At the core of Rails is the idea that most developers will perform similar tasks in similar ways. Therefore, Rails provides typical solutions, such as file structuring, naming of models, controllers, and databases. By adhering to accepted conventions, the system automatically configures many aspects of the application. For example, a model named Article will automatically correspond to the articles table in the database, without the need for additional configuration.
This frees the developer from routine configuration. Exceptional cases where customization is needed can be easily configured separately, but the bulk of tasks can be completed faster by using predefined conventions.
Eliminating excessive configuration allows for a focus on the logic of the application rather than on settings. This speeds up development and reduces the number of errors, as fewer configurations mean fewer places where a bug can occur. At the same time, this approach can also be found outside of Rails. Many modern frameworks and tools use a similar approach — from JavaScript libraries to infrastructure management systems.
CoC is one of the key approaches to simplifying the development process, where applications that adhere to established conventions require minimal configuration, and the developer gains more freedom to create functionality instead of dealing with minor settings.

Example of CoC (RoR)

Let's take a closer look at an example of CoC to understand where we save time and reduce the likelihood of bugs due to added custom code.
coc-scheme.png
  1. The developer creates a model – for example, the Article model in Rails.
  2. Since Convention over Configuration implies the use of conventions, Rails automatically expects that the table for this model will be named articles (the standard plural for English nouns).
  3. Rails automatically connects this model to the articles table in the database, without the need for additional settings. If the convention fits, no additional configuration is required.
This approach frees from unnecessary configuration, as the system relies on typical settings.
In simple terms - the framework already has common configurations that do not need to be invented independently; you just need to follow the conventions for everything to work "out of the box".

This post doesn't have any additions from the author yet.

What is SCM (Source Control Management)?
21 Aug 21:46

What is SCM (Source Control Management)?

meme code
meme code@memecode
What hierarchy does the DOM (Document Object Model) have?
23 Aug 09:22

What hierarchy does the DOM (Document Object Model) have?

meme code
meme code@memecode
How does an artificial intelligence model work?
15 Sep 16:42

How does an artificial intelligence model work?

meme code
meme code@memecode
What does relational mean (in the context of relational databases)?
21 Sep 08:27

What does relational mean (in the context of relational databases)?

meme code
meme code@memecode
What is an RDBMS (relational database management system)?
21 Sep 08:56

What is an RDBMS (relational database management system)?

meme code
meme code@memecode
What does the ACID principle mean in programming?
24 Sep 20:31

What does the ACID principle mean in programming?

meme code
meme code@memecode
Rounding decimal numbers: mathematical rules, JavaScript, and Ruby
18 Oct 12:59

Rounding decimal numbers: mathematical rules, JavaScript, and Ruby

meme code
meme code@memecode
[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)
07 Dec 10:46

[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)

meme code
meme code@memecode
What is PORO in Ruby?
08 Dec 12:46

What is PORO in Ruby?

meme code
meme code@memecode
What is the difference between spec_helper.rb and rails_helper.rb in RSpec?
08 Dec 13:53

What is the difference between spec_helper.rb and rails_helper.rb in RSpec?

meme code
meme code@memecode
09 Dec 14:50

[Fix] No such file or directory @ rb_sysopen - tmp/pids/server.pid

meme code
meme code@memecode
What you need to know to build a successful freelance career in IT
23 Dec 16:03

What you need to know to build a successful freelance career in IT

meme code
meme code@memecode