Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, Second Edition
by Craig Larman
16.9. High Cohesion
Assign a responsibility so that cohesion remains high.
Solution
How to keep complexity manageable?
Problem
In terms of object design, cohesion (or more specifically, functional cohesion) is a measure of how strongly related and focused the responsibilities of an element are. An element with highly related responsibilities, and which does not do a tremendous amount of work, has high cohesion. These elements include classes, subsystems, and so on.
A class with low cohesion does many unrelated things, or does too much work. Such classes are undesirable; they suffer from the following problems:
hard to comprehend
hard to reuse
hard to maintain
delicate; constantly effected by change
Low cohesion classes often represent a very “large ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access