Cohesion is an important concept in OO programming. It indicates whether a class represents a single abstraction or multiple abstractions. The idea is that if a class represents more than one abstraction, it should be refactored into more than one class, each of which represents a single abstraction.
Despite its importance, it is difficult to establish a clear mechanism for measuring it. This is probably due to the fact that good abstractions have deep semantics and a class that is clearly cohesive when viewed from a semantic point of view may not be so when viewed from a purely symbolic point of view.
As an aside, the somewhat inelegant name is due to the wish to have lower metric values representing a 'better' situation.
I have selected four definitions of lack of cohesion. That of Chidamber and Kemerer, that of Henderson-Sellers, and two of my own.
Note 1: I have only included methods if they access at least one field.
Note 2: I have only included fields if they are accessed by at least one method in the class.