Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
2 user(s) are online (2 user(s) are browsing encyclopedia)

Members: 0
Guests: 2

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

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:

  • Coincidental cohesion - Coincidental cohesion is when parts of a module are grouped arbitrarily; the parts have no significant relationship (e.g. a module of frequently used functions).
  • Logical cohesion - Logical cohesion is when parts of a module are grouped because of a slight relation (e.g. using control Coupling#Computer programming to decide which part of a module to use, such as how to operate on a bank account).
  • Temporal cohesion - Temporal cohesion is when parts of a module are grouped by when they are processed - the parts are processed at a particular time in program execution (e.g. a function which is called after catching an exception which closes open files, creates an error log, and notifies the user).
  • Procedural cohesion - Procedural cohesion is when parts of a module are grouped because they always follow a certain sequence of execution (e.g. a function which checks file permissions and then opens the file).
  • Communicational cohesion - Communicational cohesion is when parts of a module are grouped because they operate on the same data (e.g. a method updateStudentRecord which operates on a student record, but the actions which method performs are not clear).
  • Sequential cohesion - Sequential cohesion is when parts of a module are grouped because the output from one part is the input to another part (e.g. a function which reads data from a file and processes the data).
  • Functional cohesion - Functional cohesion is when parts of a module are grouped because they all contribute to a single well-defined task of the module (a perfect module).
  • 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=

  • List of object-oriented programming terms