Separation of concerns
Keeping different responsibilities in different places in the code.
Separating presentation, business logic and data access keeps each easier to change and test. Mixing them makes small changes risky. The principle applies at every scale, from a function to a whole system.
Why it matters for a product engineer
Separating concerns means each responsibility lives in one place: how things look, the rules, data access, logging or privacy. Each part is then easier to change and to test. When concerns are mixed, a small change in one becomes risky for all the others. The principle applies at every scale, from one function to a whole system.
How to do it
- Name the concerns in a feature: what it shows, the rules it follows, where its data comes from, and cross-cutting rules such as privacy or permissions.
- Give each concern one owner in the code, a module or a layer, and let the others call it.
- Keep business rules out of the interface, so you can test them without a browser.
- Put cross-cutting rules in one module that every feature must use, instead of a checklist that every feature must remember.
- Let dependencies point one way: presentation depends on the rules, and the rules depend on data access.
- When a change forces edits in several places, find the concern that is spread out and give it a home.
Common mistakes
- Business rules inside UI components, copied in each screen.
- Database queries in templates.
- A privacy or security rule that each feature must apply by hand.
- Layers so thin that they only pass calls along.
Example
On this site, one file collects all analytics. Page code calls it with an event name and properties, and knows nothing more. The file decides what may leave the browser and where it may go. The project’s rules for agents say to use this file and no other, so a new feature cannot add tracking that skips the privacy rules.
Who does what when this site records an event
| Page code | The analytics module | |
|---|---|---|
| The event | Names it and passes properties | Keeps only allowed properties |
| The page address | Nothing | Keeps four campaign fields, drops the rest |
| Where the visitor came from | Nothing | Keeps only the site, not the full address |
| Whether to send | Nothing | Only from the live site, never from tests, previews or opted-out browsers |
Features describe what happened. One module owns the privacy rules, so they hold for every feature, including the next one.
Observedproductengineer.pro, the analytics notes and agent rules, Nov 2026
Sources: Presentation domain data layering (Martin Fowler) ↗
Resources
1- articleStart here
Presentation domain data layering ↗
Martin Fowler · 7 minThe most common way to separate concerns in an application, and why to organize by feature at the top level.