Cohesion |
This is page is a about the computer concept Cohesion , for the concept in chemistry see Cohesion (chemistry).
In computer programming, cohesion is a measure of how well the lines of source code within a module (programming) work together to provide a specific piece of functionality. Cohesion is an level of measurement type of measurement and is usually expressed as high cohesion or low cohesion when being discussed. Modules with high cohesion tend to be preferable because high cohesion is associated with several desirable traits of software including robustness, reliability, reusability, and understandability whereas low cohesion is associated with undesirable traits such as difficult to maintain, difficult to reuse, and difficult to understand.
Cohesion is a qualitative measure meaning that the source code text to be measured is examined using a rubric (academic) to determine a cohesion classification. The types of cohesion, in order of lowest to highest, are as follows:
Since cohesion is a ranking type of scale, the ranks do not indicate a steady progression of improved cohesion. Studies by various people including Larry Constantine and Edward Yourdon as well as others indicate that the first two types of cohesion are much inferior to the others and that modules with communicational cohesion or better tend to be much superior than lower types of cohesion. The seventh type, functional cohesion, is considered the best type.
However, while functional cohesion is considered the most desirable type of cohesion for a software module, it may not actually be achievable. There are many cases where communicational cohesion is about the best that can be attained under the circumstances. However the emphasis of a software design should be to maintain module cohesion of communicational or better since these types of cohesion are associated with modules of lower lines of code per module with the source code focused on a particular functional objective with less extranous or unnecessary functionality, and tend to be reusable under a greater variety of conditions.
Cohesion is usually contrasted with Dependency (computer science). High cohesion often correlates with low coupling, and vice versa. The software quality metrics of coupling and cohesion were defined by Larry Constantine from analysis he conducted of the source code of several programming projects while with IBM to try to determine the characteristics of good programming practices.
See Yourdon, E, Constantine, L L. Structured Design: Fundamentals of a Discipline of Computer Program and Systems Design, copyright 1979 by Prentice-Hall, Inc. Published by Yourdon Press.
=See also=
|
|