What does "high cohesion" mean inside a service?
High cohesion means that all components inside a microservice perform related tasks and serve one business goal. In other words, the service's logic, data, and functions form a coherent, internally consistent whole.
The essence
Only the parts that naturally work together should live inside one service. If a service manages orders, it should contain only order-related processes: creation, status, cancellation, history.
Why this matters
- Improves clarity and resilience of the code: everything needed for one task is in one place.
- Makes maintenance and development easier: changes do not affect other services.
- Makes the system modular: one service equals one logical zone.
The opposite: low cohesion
When unrelated functions are gathered in one service (for example, orders, users, and payments together), this leads to chaos, complex logic, and a violation of the "one business function, one service" principle.
Summary:
High cohesion means everything inside a service is logically connected and works toward one goal. This makes the service autonomous, easy to understand, and easy to change.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.