Cohesive class
A class whose methods and instance variables collectively serve one closely related primary responsibility.
Software Design for Python Programmers
A cohesive class is a class whose methods and instance variables collectively serve one closely related primary responsibility.
- How it is used
- Separates class responsibilities so operations, maintenance, and cleaning can evolve without one overloaded class.
- How deep it goes
- Defines cohesion and demonstrates responsibility separation through Book/Catalogue and Automobile refactorings, without descending into formal metrics.
- Examples
- Uses Book and Catalogue classes, case-insensitive catalogue searches, and Automobile, Garage, and CarWash refactorings.
- What you can do after
- Evaluate class boundaries and refactor mixed responsibilities into smaller classes with one primary responsibility.
Read how Software Design for Python Programmers explains cohesive class →
Object-Oriented Software Design in C++
A class whose members collectively serve one clear primary responsibility.
- How it is used
- Uses single responsibility to guide class design during iterative application development.
- How deep it goes
- Defines cohesion and demonstrates refactoring responsibilities, stopping short of implementation internals.
- Examples
- Uses Book and Catalogue, then contrasts AutomobileApp with Automobile, Garage, and CarWash.
- What you can do after
- Apply the Single Responsibility Principle to split classes with unrelated state and behavior.
Read how Object-Oriented Software Design in C++ explains cohesive class →
What to know first
- methodA method is a callable function or operation associated with a type, class, or object and invoked through that association.
- classA class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
- single responsibility principleThe single responsibility principle is a software design principle that gives each component one focused responsibility and one primary reason to change.
Related concepts
- single responsibility principleimplements · The single responsibility principle is a software design principle that gives each component one focused responsibility and one primary reason to change.
- classkind of · A class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
- cohesionmeasured by · Cohesion is the degree to which the elements and responsibilities within a software unit are related and contribute to a coherent purpose.
Questions about cohesive class
What is cohesive class?
A class whose methods and instance variables collectively serve one closely related primary responsibility.
Which Manning books explain cohesive class?
Software Design for Python Programmers and Object-Oriented Software Design in C++.
What should I know before learning cohesive class?
Manning books that teach cohesive class usually introduce method, class and single responsibility principle first.
What is cohesive class a kind of?
Cohesive class is a kind of class. A class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

