Code quality metric tool like Sonar does provide the ability to drill down to a class and find out the number of:
What are these two parameters? Can you please describe with a simple contrived example?
Efferent coupling is a coupling metric in software development. It measures the number of data types a class knows about. This includes inheritance, interface implementation, parameter types, variable types, and exceptions.
We define instability metric as the ratio between efferent coupling and total coupling: I = Ce / (Ce + Ca).
What are coupling metrics? Software coupling metrics help development teams determine the complexity of their architecture based on the dependencies between classes, modules and methods.
There are 2 ways of measuring for a proper bowl size fit. One way is using a string or a OD tape to measure the hose. Another way and most accurate is using a digital caliper to measure the inside of the bowl on the coupling.
According to wikipedia:
Afferent Couplings (Ca): The number of classes in other packages that depend upon classes within the package is an indicator of the package's responsibility. Afferent = incoming.
Efferent Couplings (Ce): The number of classes in other packages that the classes in the package depend upon is an indicator of the package's dependence on externalities. Efferent = outgoing.
So, if you have classes (or packages or whatever) with the following structure:
class Foo {
Quux q;
}
class Bar {
Quux q;
}
class Quux {
// ...
}
Then Foo
and Bar
each have one efferent coupling, and Quux
has two afferent couplings.
Since you mentioned Sonar, here is the definition provided by their documentation page
Coupling is a measure of dependencies.
Afferent Coupling :
Efferent Coupling :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With