Skip to content
BENIBIX Learn

Separation of Concerns

Development🏗️ ArchitectureArchitecture Basics

Also known as SoC, Concern Separation

Giving each part of a program one job. Each part is kept apart from the rest.

Think of it like

Think of it like a kitchen with a sink, a stove and a fridge. Each spot does one job.

Example

Lucy's app mixed database calls into its page code. She moves them into their own file. Now she can change the database without touching any page.

Why it matters

It keeps changes small and safe. You can work on one part without reading the whole program.

Definition

Separation of concerns means each part of a program deals with one job. A concern is one thing the program has to handle, like showing pages, saving data or checking passwords. Code for each concern lives in its own place. Then a change to one job does not spill into the others. The web itself splits pages this way: HTML for content, CSS for looks, JavaScript for actions.

Common mistake

Splitting code into so many tiny parts that one simple change touches ten files. Split by job, not by size.

Key takeaways

  1. 1
    One job per part. Each concern on its own.
  2. 2
    Changes stay local. No spill into others.
  3. 3
    Split by job. Not just by size.