Given that the probability of a method's being updated during a project's lifetime depends entirely on whether that method partakes in the features arbitrarily desired by customers, it might have been guessed that such end-user whimsy would completely randomize any connection between method and property, such that no correlations whatsoever would exist.
Yet this was not the case.
True, most properties indeed showed no correlation. But some did. The correlations were weak, but not negligible, thus presenting at least some evidence that the following three principles really do help reduce software development cost:
Programmers have known of these principles for years: the first being rather ovious, the latter two combining to say, roughly, don't make spaghetti code. It is nevertheless reassuring to find support for these principles - however slight - carved into the actual code, rather than stemming wholesale from mere subjective opinion.
Program structure, of course, extends beyond method-level. Java enjoys at least two other levels: class-level and package-level. Can we find evidence for the above three principles at these two higher levels?
The experiment was re-run3, this time counting the number of times a class or package was updated during a project's lifetime and correlating this with the properties4 of that class or package. Table 1 shows the results for all three levels.
|Property||S.||D. f.||C. c.||T. d.||I.S.||A. p. c.||A.||C. d.||Impd. S.||C.||M.||D.||D. o.|
Looking at the average correlations over all three levels, we find - alas - many structural properties show no correlation (<0.2) with number of updates, and none shows a strong correlation. Again, however, three properties do show some correlation, albeit weak: size, number of transitive dependencies and absolute potential coupling.
Two of these properties we've encountered already and show correlations across all levels, though absolute potential coupling gains importance only at class- and package-level.
Absolute potential coupling is just the number of other elements that a given element can see. For example, a method can see all private methods in the same class, but cannot see private methods in other classes in the same package, and can only see public methods in public classes in other packages.
Thus, absolute potential coupling measures (approximately) how poorly a program is encapsulated, with this correlation showing that more methods that a given method is exposed to, the more often that method will be updated. This, once more, programmers know well.
It would be shame, however, to abandon the impact set principle at method-level simply because it loses support at class- and package-level. Thus we can summarise the findings on all levels by establishing the four evidence-based principles:
Programmers employ many structural principles in the production of high-quality code, some based on personal experience, some gleaned from books of worthy authority. These principles remain of inestimable value.
Some principles, however, exert so powerful an influence that cold statistics can harvest faint traces of their passing from source code alone. Despite the weakness of the correlations that identify these principles, they clearly boast better objective evidence than principles that lack any evidence whatsoever. These are the evidence-based principles. They in no way render other principles useless, but merely bask in the hazy sunshine of ever-so slightly increased credibility.