Skip to content
IT glossary
ProgrammingUpdated December 3, 2026

Convention over configuration

Соглашения вместо конфигурации

This approach lets a tool infer routine choices from standard names or project layouts. You only specify settings when the standard behavior doesn't fit.

What it means

Suppose every time you add a page to a site, you also have to put its URL and file path into a routing table. If those two values follow a predictable pattern, the framework can derive the URL from the file path instead. The layout of the project supplies information you would otherwise have to write down a second time. That's convention over configuration.

A convention is more than a naming preference. A team might agree to call its test folder tests, but that agreement alone doesn't make a runner look there. The convention replaces configuration only when the tool uses it to make a decision. It can also produce different results from different inputs: a fixed default picks the same value each time, while a naming rule can derive a different value for each file or class.

Example: finding tests with pytest

With pytest's standard discovery rules, a file named test_prices.py matches the test file pattern, and a function named test_total inside it matches the test function pattern:

def test_total():
    assert sum([2, 3]) == 5

Run pytest with no file arguments from the directory containing that file, and pytest can collect the test without a list of files or functions to run. If you rename the file to price_checks.py, it no longer matches the default filename pattern. If the project already uses names such as *_checks.py, you can set python_files in pytest's configuration to tell it which files to discover instead. The test itself doesn't have to change.

Where it helps and where it gets tricky

Convention-based discovery is common in test runners, web routers, and object-relational mappers. In Ruby on Rails, for instance, Active Record maps a model called Book to books by default. Developers who know that convention can tell which table the model uses without finding a separate mapping for every class.

The trade-off is that behavior can change during what looks like a harmless rename. If a test disappears from a run, check which tests were collected and compare the filename and function name against the active discovery rules before debugging the test body. Explicit configuration still makes sense when a project must preserve an existing database schema, public URL, or directory layout that doesn't fit the tool's conventions.

How it comes up in interviews

If asked for an example, name the rule, the setup it saves, and what you'd do when it doesn't fit. In the pytest example, the filename pattern replaces a manually maintained list of test files. A custom discovery pattern is useful when renaming the existing suite would be more disruptive than adding one configuration setting.