The degree to which different elements inside a module “belong” together.
Cohesion is something that happens inside a system component. Unlike Coupling, cohesion is intra-component.
Sometimes it is hard to determine where to draw the line between adding a feature to an existing system component or adding a new component to the system to encapsulate a feature.
In general, high-cohesion is good.
Example of High-cohesion
- A hammer - the Perfect Tool
Example of Low-cohesion
- Microsoft Word dumping a ton of features in about mail merge