|
The efferent coupling of a type is the number of other types that
it directly depends on.
One type t depends on another type dep if
t makes use of dep in some way. More precisely:
- t is a direct subtype of (implements or extends) dep
- t declares a field of type dep
- t declares a method or constructor that
- has dep as its return type
- has a parameter of type dep
- throws an exception of type dep
- calls a method declared in type dep
- accesses a field declared in dep
Pre-packaged Query
Query name = "Semmle/Metrics/Types/Reftypes with high efferent coupling"
Reports types in the source that have an efferent coupling of more than
35, in descending order, as a bar chart.
from MetricRefType t, int n
where t.fromSource() and
n = t.getEfferentCoupling() and
n > 35
select t,n order by n desc
.QL Source of Metric
This metric is defined in the class MetricRefType,
and it is very straightforward:
int getEfferentCoupling() {
result = count(RefType t | depends(this,t))
}
For a further discussion of the depends relation,
please refer to the documentation of
Afferent Coupling.
References
Robert C. Martin. OO Design Quality Metrics. October 24, 1994.
Robert C. Martin.
Agile Software Development, Principles, Patterns and Practices.
Addison Wesley, 2002.
Andrew Glover.
In Pursuit of Code Quality: Code Quality for Software Architects.
April 2006.
Jack Shirazi and Kirk Pepperdine.
Eye on performance: Determining the riskiness of change.
July 2004.
|