ITWissen.info - Tech know how online

cohesion

The cohesion determines a measure of the strength of the internal connection of a module. In terms of software engineering, a module defines a coherent program code with a common name under which it can also be identified and called by other program parts. The possible characteristics of a cohesion are classified thereby on a scale of one to seven. The highest level of seven is assigned to systems with functional decomposition. Modules that are easy to maintain and reuse are based on strong cohesion. Cohesion is a criterion for modularization along with coupling, data encapsulation and information hiding.

In software engineering there were already early approaches, which argued with the topic of the cohesion. Here one assumed at first to summarize similar functions. That led in the consequence however not necessarily to a stable system structure. In connection with the object-oriented programming in addition, the aspect-oriented programming the concept of the cohesion has a central meaning, so that the following differentiation seems meaningful:

Random cohesion. Is called also the condition of completely missing cohesion. In this case, a module implements sequences of program statements that are not related to each other in any way.

Logical cohesion. The actions of a module are directly related to each other and can be specifically addressed by the calling module, for example, by explicitly passing a parameter.

Temporal cohesion. The actions of a module are temporally related to each other.

Procedural cohesion. The actions of a module are implemented in a specific sequence of steps.

Communicative cohesion. Assumes procedural cohesion first and access to a common dataset.

Object-based cohesion. Several actions are implemented in a module, but they are implemented completely independently of each other, but access a common dataset. Typical examples of object-related cohesion are the implementation of an abstract data type or an object.

Functional cohesion. A module is responsible for exactly one action.

Thus, the determination of cohesion as a measure of the togetherness of the statements within a module can be read directly on a scale starting with one (= random cohesion) and ascending to seven (= functional cohesion).

Better cohesion for a module is essentially achieved by

  • the principle of the data encapsulation in the sense of the object-oriented software development is converted - i.e. no global data objects,
  • the rules for the formation of packages are kept,
  • with the object-oriented software development data structures(instance variables) and operations(methods) closely with one another connect,
  • not several operations serve the same function,
  • interfaces between modules must be designed efficiently
  • a reasonable combination of coupling and cohesion is observed, and
  • that there is no partitioning into subsets of methods and attributes that originally belonged together. Here one speaks also of coherent classes.

Also the aspect-oriented programming supports a high measure of cohesion, since here the functional cohesion is a fundamental goal. This goal is reached exactly, if an action isolated from the environment is executed, one calls this also Crosscutting behavior. The mentioned other differentiations do not come into consideration with the aspect-oriented programming because

  • the logical cohesion would presuppose the possibility of a direct call,
  • with the temporal, procedural as well as communicative cohesion a temporal and contentwise sequence is presupposed, which contradicts the Crosscutting behavior and
  • the assignment of aspects to the object-oriented cohesion is likewise not possible, because aspects always orient themselves at the behavior and not at the data. If aspects were oriented exclusively to a common dataset, several functions would in turn be integrated into each other - neither functional cohesion nor the reusability of this aspect would then be representable.

A high degree of cohesion of a module thus facilitates its understanding as well as its maintenance and possible adaptation.

Informations:
Englisch: cohesion
Updated at: 29.10.2013
#Words: 613
Links: connection, indium (In), software engineering (SE), program, code
Translations: DE
Sharing:    

All rights reserved DATACOM Buchverlag GmbH © 2024