|
The afferent coupling of a package is the number of types
outside this package that directly depend on types inside this package.
A high afferent coupling is an indication that the package
has many responsibilities; it may thus be a good idea to
consider whether these responsibilities can be separated into
separate packages.
The main purpose of afferent coupling, however, is to define
further metrics.
The precise definition of dependence between types is discussed
under
Afferent Coupling of a Type.
Pre-packaged Query
Query name = "Semmle/Metrics/Packages/Coupling/Packages that have high afferent coupling"
Packages that have afferent coupling greater than 20, in descending
order, as a bar chart.
from MetricPackage p, int c
where p.fromSource() and c = p.getAfferentCoupling() and c > 20
select p, c order by c desc
.QL Source of Metric
This metric is defined in MetricPackage, and its definition
reads:
int getAfferentCoupling() {
result = count(RefType t |
t.getPackage() != this
and
exists(RefType s |
s.getPackage()=this
and
depends(t,s)))
}
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.
|