Cohesion
Cohesion describes the relatedness of the steps that the designer puts into the same segment of code, for example, a function.
When a function has good cohesion (high cohesion), it performs one task over one computational object or data structure; when cohesion is poor (weak cohesion), the function performs several tasks over one object or even several tasks over several objects. When the function exhibits poor cohesion, it contains diverse unrelated computations over unrelated computational objects. This means that these objects belong elsewhere: The designer tore apart things that should have belonged with something else and instead put them into the same function.
High-cohesion functions are easy to name. Usually, one uses a verb-plus- ...
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