UMBC CS 201, Spring 02
UMBC CMSC 201 Spring '02 CSEE | 201 | 201 S'02 | lectures | news | help

Cohesion

Cohesion is the degree of interrelatedness of internal parts. All of the elements of a component are directed towards and are essential for the same task, ("A function should do one thing, and only one thing"). We should try to MAXIMIZE Cohesion.

Degrees of Cohesion

How much cohesion?

Example of Coincidental Cohesion

All of the following in one module:

Example of Logical Cohesion

Display time and date on the screen Prompt user for user-id Look up user-id in USER list If found: Prompt for password Validate password Process course enrollment request Else if not found: do error processing

Example of Temporal Cohesion

Related only by the time they need to be done, i.e. at the beginning of the program Initialize two arrays Initialize several variables Seed the random number generator Print a greeting

Example of Functional Cohesion

Each in a separate module:


CSEE | 201 | 201 S'02 | lectures | news | help

Thursday, 17-Jan-2002 13:52:15 EST