Cohesion and coupling

In object-oriented programming (OOP), cohesion and coupling are two fundamental concepts. The basic principle is to have classes with loose coupling and high cohesion. Loose coupling enables modularized packages that do not heavily rely on each other, while high cohesion provides tight and solid components with clearly defined responsibilities. High coupling means that a class relies on many other classes, while low cohesion signals for a class could be split into separate ones, offering fine-grained functionality.

Afferent coupling

Afferent (incoming) coupling is the total number of classes that depend on a given class. In Sonar, you can view afferent coupling within the Sonar source viewer under the Dependencies tab. For ...

Get Sonar Code Quality Testing Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.