🏗️Cohesion
Also known as High Cohesion, Low Cohesion
How well the code in one part fits together.
Think of it like
Think of it like a toolbox that only holds tools. You never find socks in it.
Example
Lucy's utils file holds date code, email code and price maths. She splits it into three files. Each one now has a clear name and purpose.
Why it matters
When code that belongs together sits together, a change happens in one place. You do not hunt for it.
Definition
Common mistake
Key takeaways
- 1One purpose. Per module.
- 2Easy to name. A sign it is focused.
- 3Pairs with loose coupling. Two sides of one goal.