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 Sonvention over Sonfiguration (in the context of RoR and beyond)?

Post cover: What is Sonvention over Sonfiguration (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) <TAG1> is the principle that the system or framework already has default configurations, allowing the developer to avoid writing/creating settings themselves. This greatly reduces the number of decisions to be made and reduces the time for customization and development in general.
For the first time, this approach gained popularity thanks to the framework Ruby on Rails. Rails is based on the idea that most developers will perform similar tasks in similar ways. Rails therefore provides typical solutions such as file structuring, model names, controllers and databases. If you follow the accepted agreements (conventions), the system automatically configures many aspects of the program. For example, a model named Article will automatically match the articles table in the database, without the need for additional configuration.
This frees the developer from the routine configuration. Exceptional cases where individualization is required are easily configured separately, but the main scope of tasks can be performed faster using predetermined conventions.
Getting rid of overconfiguration allows you to focus on the logic of the program, not on the settings. This speeds up development and reduces errors, as fewer configurations mean fewer places where bag can be. At the same time, this approach can 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 comply with established agreements require minimal configuration, and the developer gets more freedom to create functionality instead of working with small settings.

Example CoC (RoR)

Let's take a closer look at the CoC example to understand exactly where we save time and reduce the likelihood of bugs due to the added custom code.
coc-scheme.png
  1. The developer creates a model <TAG1> for example, the Article model in Rails.
  2. Since Convention over Configuration involving the use of agreements (conventions), Rails automatically expects the table for this model to be called articles (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 agreement is suitable, no additional configuration is required.
This approach frees from redundant configuration, as the system relies on typical settings.
If in simple words, the framework already has general configurations that you don't need to invent yourself, but you just need to follow the conventions so that everything works "right 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
Як працює модель штучного інтелекту?
15 Sep 16:42

Як працює модель штучного інтелекту?

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 RDBMS (relational database management system)?
21 Sep 08:56

What is 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
Округлення десяткових чисел: математичні правила, JavaScript і Ruby
18 Oct 12:59

Округлення десяткових чисел: математичні правила, JavaScript і Ruby

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

[Фікс] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)

meme code
meme code@memecode
Що таке PORO в Ruby?
08 Dec 12:46

Що таке PORO в 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

[Фікс] 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