9.1. Coupling and Cohesion

Of all of the fancy terms associated with object orientation, two of the simplest are too often forgotten. In fact, any discussion on inheritance, polymorphism, or composition is really talking about coupling and cohesion. Informal definitions for these terms follow:

  • Coupling: The degree to which classes within our system are dependent on each other.

  • Cohesion: The measure of how much an entity supports a singular purpose within a system.

Our goal when designing a system should be to reduce coupling and increase cohesion. A system that is loosely coupled implies the number of relationships among all classes in our system has been kept to the minimum. Obviously, classes must have relationships to each other; otherwise, ...

Get Java™ Design: Objects, UML, and Process now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.