CSC/ECE 517 Fall 2012/ch1b

From Expertiza_Wiki
Jump to navigation Jump to search

Cohesion refers to the degree that a module performs one and only one function. In this context, a module refers to any logical collection of “program entities” [2]. This logical collection of program entities could be a function, a class, or even a package. As stated earlier, the goal of object-oriented programming is to achieve highly cohesive classes. High cohesion is desired because it increases the likelihood that a module will be comprehendible, reliable, robust, and reusable [3]. Alternatively, a module that exemplifies low cohesion is difficult to comprehend, costly to maintain, and less likely to be reused [4]. The following examples illustrate the different types of cohesion and are arranged from lowest (least desirable) to highest (most desirable).