October 2, 2007
Package Afferent Couplings & Normalised Distance from Main Sequence - Simulation #2It's just gone midnight, and as promised, I've noodled with the change propagation simulation into the wee small hours (taking a break to watch the UK premier of The Riches, which looks fantastic, BTW).
I added packages and randomly grouped types into them. I then calculated the "abstractness" and instability of each package. (I'm using "" because, strictly speaking, I'm actually classing types with a lower probability of change as "abstract". The reality is less clear, but I wanted to stick with Robert Martin's definitions for now so I could at least use his package coupling metrics without changing the definitions and confusing everybody - including myself.
Same MO as before - I randomly generated 1000 type systems, each made up of 100 types - some with a probability of change of 1.0 (which we shall call "concrete" types for now) and some with a probability of change of 0.5 (which we'll call "abstract" for the purposes of this exercise). Then these types are randomly added to one of 10 packages. As the simulation progresses, the chances of "abstract" types being packaged together increases (and therefore, the dependencies on packages with a higher "abstractness" increases). This ensures we get a wide range of package coupling scenarios.
If you've not come across the Normalised Distance from the Main Sequence (D') metric, you can find a brief explanation in this tutorial. D' was calculated for every package, and the resulting data output from the simulation includes to average of D' for each simulation.
We then plot D' against the number of packages changed when we drop our random change in each type system. The results are somewhat surprising:
I couldn't fathom why the extent of change propagation actually seemed to decrease as D' increases - since the whole point of D' is to warn us of the exact opposite.
But when I plotted extent of change propagation against package afferent couplings, the picture seems much clearer. With more incoming dependencies - more channels along which change can propagate - we would naturally expect the change to spread further.
The code I wrote to increasingly group abstract types into the same packages seems somehow to increase the average number of package afferent couplings in each type system. My theory is that if we increasingly separate concrete and abstract types into different packages, then the dependencies between these types will increasingly be inter-package as opposed to intra-package.
I'm not at all surprised that increasing package afferent couplings increases the extent of change propagation, though. regardless of D', it seems, this is a major factor in change propagation at the package level.
I gues snow I need to find a way to test D' with a fixed number of package afferent couplings, to see what difference it makes by itself. One frig might be to incrementally reduce the proportion of dependencies on abstract types, so that abstract packages are smaller and necessarily have less afferent couplings.
Phew, this is hard work!
Posted 13 years, 2 months ago on October 2, 2007