O'Reilly logo

Sonar Code Quality Testing Essentials by Charalampos Arapidis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required