UMBC CS 201, Fall 05
UMBC CMSC 201 Fall '05
CSEE | 201 | 201 F'05 | lectures | news | help


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 F'05 | lectures | news | help

Sunday, 21-Aug-2005 09:53:38 EDT