October 30, 2007
Fleshing Out A Reusable Code Model for Analysis & MetricsA more sophisticated design quality test would probably require a more sophisticated model of our code than a framework like Cecil, the .NET IL dis-assembler, comes with out of the box.
Package coupling for example, requires extra information from our code model that would have to be added in order to calculate, for example, normalised distance from the main sequence (D'). The act of writing programmatic - computable - definitions of these metrics further tests our understanding of what the metrics mean.
And it's a perennial disappointment to me that there's nowhere I can can go to get a definitive, testable, computable definition of established metrics, perhaps with multiple examples of how it maps on to different programming languages and platforms.
I've demonstrated in the past that UML can be used to create precise specifications of performance measures, expressed using the Object Constraint Language against a domain model that includes all the relevant types of objects required to express the metrics. By creating testable metric specifications, we can - well, er - test them. We can also communicate them more effectively (to other OCL speakers, of course - which is where it all falls down, sadly). And, last but not least, we can more readily implement them using object oriented programming languages like C#, Java and SmallTalk.
To illustrate this, I've knocked up an example UML specification of D' using a small model that describes packages, types inside packages and dependencies between types (and derived dependencies between packages, therefore).
I don't know about you, but I find this kind of model quite useful as an aid to fleshing out and formalising my understanding of these metrics. I'm sure if I were to incrementally add more and more metrics, my model of the code should become more comprehensive and robust. It would be a useful step from there to implement this model as a framework that could be reused in the kinds of design quality unit tests I've mentioned in previous blog posts.
Populating this model from the output of a tool like Cecil would be the next logical step.
Posted 13 years, 9 months ago on October 30, 2007