Skip to content
>devspeak
← glossary
level 7Architecture

Separation of concerns

The principle that each part of your code should handle one kind of job, like showing the screen, applying business rules, or saving data, instead of mixing them.

a bit more technical

A design principle that divides a program so each section addresses one distinct concern: presentation, business logic, data access, authentication. Mixing concerns, such as database queries inside UI components, makes code harder to change, test and reuse.

picture it

In a clinic, reception checks you in, nurses take vitals, doctors diagnose and the billing office sends invoices. If the doctor also ran billing, both jobs would suffer.

why it matters

Agents told to "just make it work" often mix concerns: database calls in a button's code, pricing rules in an email template. Asking for separation keeps future changes small and testable.

what your agent might say
agent
The discount rules are currently inside the React component. For separation of concerns, I'll move them to src/pricing so the component only displays the result.
how you might use it
you → your agent
Keep separation of concerns: the component should only display data. Put the validation rules and the database calls in separate files.
common mistake

Thinking it means one file per function or splitting everything into tiny pieces. It's about not mixing different kinds of jobs, not about file count.

builds on