Instability of a Package

Instability is a measure of how hard it is to change a package without impacting other packages within an application.

If this metric value is high, it is hard to make changes, if it is low, it is likely to be easy. Instability is estimated as the number of outgoing dependencies relative to the total number of dependencies. Of course it is easy to create very stable classes: just don't use them at all - then a change will be very easy, and the afferentCoupling value is 0, so the instability is 1. There is a tension, therefore, between stability and usefulness.

Pre-packaged Query

Name of query = "Semmle/Metrics/Packages/Packages that are unstable"

Reports packages with instability greater than 0.8.

from MetricPackage p, float c
where p.fromSource() and c = p.getInstability() and c > 0.8
select p, c order by c desc

.QL Source of Metric

This metric is defined in MetricPackage. Its definition reads:

    float getInstability() {
        exists(int ecoupling, int sumcoupling |
ecoupling = this.getEfferentCoupling() and
sumcoupling = ecoupling + this.getAfferentCoupling() and
sumcoupling > 0 and
result = ecoupling / sumcoupling) }

Please refer to the documentation of Afferent Coupling of a Package and of Efferent Coupling of a Package for further details of the respective definitions.

References

Robert C. Martin. OO Design Quality Metrics. October 24, 1994.

Robert C. Martin. Agile Software Development, Principles, Patterns and Practices. Addison Wesley, 2002.

Objecteering. Metrics in detail: Instability . 2007.

Bill Venners. How Useful are Code Metrics? Artima Developer, April 26, 2006.

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

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