Friday, May 29, 2009

Cohesion

Cohesion is a measure of degree of how strongly a class focuses on its responsibilities. It is of the following two types:

  • High cohesion: This means that a class is designed to carry on a specific and precise task. Using high cohesion, methods are easier to understand, as they perform a single task.
  • Low cohesion: This means that a class is designed to carry on various tasks. Using low cohesion, methods are difficult to understand and maintain.
In object-oriented design, high cohesion is desirable, as it is easy to understand and maintain. Moreover, it is easier to reuse.

No comments:

Post a Comment