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- ...
Get Core C++ A Software Engineering Approach 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.