jargon

Comparison

CohesionvsInterface segregation principle

Cohesion

the code for one job is spread over four files, and each of those files also does three unrelated jobs.

How much the things inside one module belong together. High cohesion means a module has one reason to exist and everything in it serves that reason; low cohesion means the module is a drawer. It matters because cohesion is what makes a boundary findable: when the code that changes together lives together, a feature is one file to open rather than a search across the repository.

Full entry →

Interface segregation principle

you implemented an eleven-method interface to get at one of them and threw not-implemented from the other ten.

The principle that a client should not be forced to depend on methods it does not use, which in practice means preferring several small role interfaces to one large one. The observable cost of getting it wrong is not aesthetic: every implementer is recompiled and every test double is rewritten when an unrelated method is added to the fat interface. Role interfaces also make it obvious what a collaborator is actually for, because the name describes the role rather than the class.

Full entry →

Related comparisons