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 themselves. 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. If the accepted conventions are followed, 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; however, the bulk of tasks can be completed faster by using predefined conventions.
Eliminating excessive configuration allows focusing on the logic of the program 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 working 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 the table for this model to 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 necessary.
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; 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
Як працює модель штучного інтелекту?
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