# Cohesion

> How well the code in one part fits together.

**Field:** Software Development  
**Category:** Architecture  
**Also known as:** High Cohesion, Low Cohesion

## Think of it like

Think of it like a toolbox that only holds tools. You never find socks in it.

## Definition

Cohesion is how well the code in one part of a program fits together. High cohesion means every function in a module serves the same purpose. Low cohesion means a module is a grab bag of unrelated jobs. High cohesion makes code easy to find and easy to name. It goes with loose coupling. Parts that do one thing need each other less.

## 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.

## Common mistake

Making a file called helpers or utils and putting all sorts in it. It soon gets the hardest file to change.

## Three principles

- **One purpose.** Per module.
- **Easy to name.** A sign it is focused.
- **Pairs with loose coupling.** Two sides of one goal.

## Related terms

- [Coupling](https://learn.benibix.com/term/development/coupling)
- [Separation of Concerns](https://learn.benibix.com/term/development/separation-of-concerns)
- [Clean Code](https://learn.benibix.com/term/development/clean-code)
- [SOLID Principles](https://learn.benibix.com/term/development/solid-principles)

## Told apart from

- [Coupling vs Cohesion](https://learn.benibix.com/compare/coupling-vs-cohesion): Coupling and cohesion are both ways to judge how well code is split, but they look at different things. Coupling is how much one part leans on other parts. Cohesion is how well the code inside one part fits together. Good design aims for low coupling and high cohesion. Each part does one thing and needs little from the rest.

---

Source: https://learn.benibix.com/term/development/cohesion
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
