Cohesion
Cohesion is the degree to which the elements and responsibilities within a software unit are related and contribute to a coherent purpose.
Grokking Software Architecture
Cohesion is the degree to which the responsibilities within a software component belong together.
- How it is used
- Uses cohesion alongside coupling to assess whether responsibilities are separated into maintainable components.
- How deep it goes
- Defines high and low cohesion through analogies and contrasting classes, then provides a comment-driven audit.
- Examples
- Contrasts a shipping-cost class with a class mixing authentication, logging, and currency formatting, and examines an anemic Order object.
- What you can do after
- Practice performing a comment-driven structural audit to spot unrelated responsibilities in a method or class.
Microservices Patterns, Second Edition
Cohesion is the degree to which the elements or responsibilities within a software component belong together.
- How it is used
- Guides grouping decisions that localize changes and support modifiability and team autonomy.
- How deep it goes
- Defines cohesion through tightly coupled child elements and explains its consequences across the software design hierarchy.
- Examples
- Uses Customer Management and Order Management to illustrate how coupling affects the spread of changes between subdomains.
- What you can do after
- Evaluate and understand grouping decisions by considering change localization and microservice boundary trade-offs.
Read how Microservices Patterns, Second Edition explains cohesion →
The Coder Cafe
Cohesion is a software design property describing how strongly the elements within an aggregate belong together and serve a common purpose.
- How it is used
- Assesses whether the parts of a function, class, or module serve a common purpose.
- How deep it goes
- Defines cohesion, illustrates high and low cohesion, and identifies benefits and code smells.
- Examples
- Contrasts bedroom contents serving unrelated purposes with contents supporting rest and morning preparation.
- What you can do after
- Evaluate/understand it by checking whether an aggregate's parts share a purpose and recognizing signs of scattered responsibility.
Functional Design and Architecture: Examples in Haskell
Cohesion is the degree to which the responsibilities and internals of a software component belong together.
- How it is used
- Uses cohesion with coupling to keep complexity manageable during object-oriented and functional design.
- How deep it goes
- Defines blurred responsibility, diagnoses a coupled implementation, and refactors it through interfaces without detailing cohesion metrics.
- Examples
- Uses a thermometer-to-server Observer, ISensor and IConnection interfaces, and an analogous Haskell temperature workflow.
- What you can do after
- Evaluate and refactor components by isolating responsibilities behind interfaces and checking cohesion across object-oriented and functional code.
Read how Functional Design and Architecture: Examples in Haskell explains cohesion →
Architecture Modernization: Socio-technical alignment of software, strategy, and structure
The degree to which the concepts, events, rules, and activities within a subdomain are mutually related and form a coherent whole.
- How it is used
- Uses related concepts and coordinated change to shape subdomain boundaries, team ownership, and sustainable evolution.
- How deep it goes
- Analyzes purpose, event consistency, relatedness, team ownership, and coordinated change, stopping short of implementation detail.
- Examples
- Uses loyalty levels, Pickup and Dropoff events, and iterative accounting boundary designs as concrete examples.
- What you can do after
- Apply it via subdomain descriptions, sense-check questions, concrete scenarios, and a subdomain overview canvas to refine boundaries.
The Art of Code
High cohesion is a software-design condition in which a component's parts are closely related and focused on one responsibility.
- How it is used
- Guides separation of concerns by keeping responsibility-specific logic together within modules, layers, or classes.
- How deep it goes
- Explains cohesion through a class-level before-and-after example and connects it to coupling, without descending into implementation internals.
- Examples
- Uses OrderTools, PricingService, NotificationService, and architecture-review signals such as large classes and misplaced responsibilities.
- What you can do after
- Evaluate components for unrelated responsibilities and reorganize them into focused units with clearer boundaries.
Shipping Go: Develop, deliver, discuss, design, and go again
Cohesion is the degree to which the responsibilities of a software module or component belong together.
- How it is used
- Guides grouping service responsibilities into focused interfaces and components early in development.
- How deep it goes
- Defines high and low cohesion and illustrates each with class examples, without offering a measurement method.
- Examples
- Contrasts Validation with UserRegistrationValidation and broad responsibilities with clearly defined structures.
- What you can do after
- Evaluate whether a component groups one well-defined task or combines broad responsibilities.
Read how Shipping Go: Develop, deliver, discuss, design, and go again explains cohesion →
Also covered in
- Practices of the Python Pro
- Object-Oriented Software Design in C++
- Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform
- Software Design for Python Programmers
What to know first
- classA class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
- methodA method is a callable function or operation associated with a type, class, or object and invoked through that association.
- interfaceAn interface is a contract or boundary that specifies the operations, members, or data shape a type or component exposes, without prescribing its complete implementation.
- componentA software component is a modular part of a software system that encapsulates related functionality and interacts with other parts through defined boundaries.
Related concepts
- design-time couplinguses · The degree to which software elements must be designed or changed together because of dependencies between them.
- microservice architectureused by · Microservice architecture is a software architectural style that structures an application as independently deployable services, typically organized around focused capabilities and communicating through defined interfaces.
Questions about cohesion
What is cohesion?
Cohesion is the degree to which the elements and responsibilities within a software unit are related and contribute to a coherent purpose.
Which Manning books explain cohesion?
Grokking Software Architecture, Microservices Patterns, Second Edition, The Coder Cafe, Functional Design and Architecture: Examples in Haskell, Architecture Modernization: Socio-technical alignment of software, strategy, and structure, The Art of Code and Shipping Go: Develop, deliver, discuss, design, and go again.
What should I know before learning cohesion?
Manning books that teach cohesion usually introduce class, method, interface and component first.
What kinds of cohesion are there?
Kinds of cohesion include communicational cohesion and sequential cohesion.
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.






