3 December 2024

Class Coupling and Cohesion

Class Coupling definition

  • It is a code quality metric.
  • Class coupling is a measure of the dependencies a class has on other classes.
    • A measure of how many classes a single class uses.
    • Class coupling measures each class only once for this metric no matter how many times it gets used.

Class Coupling purpose

  • Class Coupling is Code Metric which checks the Code Health.

Class Coupling practice

  • Coupling is the degree of interdependence between software modules;
    • a measure of how closely connected two routines or modules are;
    • the strength of the relationships between modules.
    • High is bad, low is good.
  • The code metric class coupling measures the coupling to unique classes through parameters, local variables, return types, method calls, generic or template instantiations, base classes, interface implementations, fields defined on external types, and attribute decoration.
    • High class coupling indicates a design that is difficult to reuse and maintain because of its many inter dependencies on other types.
    • When this coupling is high, we may assume that the software modules are interdependent, i.e., they cannot function without the other.

Cohesion

  • Cohesion is a measure of the degree to which the responsibilities of a single module or a component form a meaningful unit.
    • Cohesion describes how related the functions within a single module are.
    • High is better.
  • Cohesion makes software easier to understand, reduces the effects a change on one part of the system has on the rest of the system, and it allows us to reuse code within our application.

Coupling and Cohesion

  • In software engineering, coupling is the degree of interdependence between software modules;
    • a measure of how closely connected two routines or modules are;
    • the strength of the relationships between modules.
  • Coupling is usually contrasted with cohesion.
    • Low coupling often correlates with high cohesion, and vice versa.
    • Low coupling is often thought to be a sign of a well-structured computer system and a good design, and when combined with high cohesion, supports the general goals of high readability and maintainability.

Module Coupling and Class Coupling

Scrum and Metrics

The Scrum framework

More informations for the Scrum PSD certification here.

Updated : 01/10/2021

Leave a Reply

Your email address will not be published. Required fields are marked *