Cohesion
ELI5 — The Vibe Check
Cohesion is how well the things inside a module belong together. High cohesion means all the stuff in a class is related — like a toolbox full of tools. Low cohesion means the class is a junk drawer — a random mix of unrelated stuff. High cohesion = good.
Real Talk
Cohesion measures how strongly related the responsibilities within a single module are. High cohesion means a module focuses on a single purpose with all its elements contributing to that purpose. Low cohesion indicates the module does too many unrelated things.
When You'll Hear This
"This service has low cohesion — it handles users, payments, AND emails." / "High cohesion and low coupling is the golden goal."
Related Terms
Coupling
Coupling is how much two pieces of code depend on each other. Tight coupling means changing one breaks the other — like Siamese twins.
Refactoring
Refactoring is improving the internal structure of code WITHOUT changing what it does from the outside.
Separation of Concerns
Separation of Concerns means different parts of your code should handle different concerns and not step on each other's toes.
Single Responsibility
Single Responsibility means every class or function should do ONE thing and do it well.