Afferent Coupling of a Method (Incoming Dependencies; Fan-in)

The number of callables (constructors or methods) that may call this callable, either directly or as the result of overriding.

Callables with a high afferent coupling are important and must be tested thoroughly.

Pre-packaged Query

Query name = "Semmle/Metrics/Methods/High afferent coupling (fanin) methods"

Lists methods with an afferent coupling greater than 50, in descending order, as a bar chart.

from MetricCallable c, int n
where c.fromSource() 
      and 
      n=c.getAfferentCoupling()
      and
      n > 50
select c, n order by n desc

.QL Source of Metric

This metric is defined in the class MetricCallable. It consists both of the definition of an appropriate notion of dependency, and the metric computation itself:

   MetricCallable getADependency() {
      this.polyCalls(result)
   }

   int getAfferentCoupling() {
      result = count(MetricCallable m | m.getADependency() = this )
   }

References

Marius Marin, Arie van Deursen, Leon Moonen. Identifying aspects using fan-in analysis Proceedings of the 11th Working Conference on Reverse Engineering, pages 131-142, 2004.

Digg!Reddit!Del.icio.us!Facebook!Slashdot!Technorati!StumbleUpon!Ma.gnolia!

Comments
Only registered users can write comments!
 
< Prev   Next >