views:

35

answers:

2

One of the things I’ve been thinking about a lot off and on is how we can use metrics of some kind to measure change, are we going backwards or not? This is in the context of a large, legacy code base which we are improving. Most of the code is C++ with a C heritage. Some new functions and the GUI are written in C#.

To start with, we could at least be checking if the simple complexity level was changing over time in the code. The difficulty is in having a representation – we can maybe do a 3D surface where a 2D map represents the code and we have a heat-map of color representing complexity with the 3D surface bulging in and out to show change.

Once you can generate some matrics of numbers there are a ton of math systems around to take care of stuff like this.

Over time, I'd like to have more sophisticated numbers in there but the same visualisation techniques used to represent change.

I like the idea in Crap4j of focusing on the ratio between complexity and number of unit tests covering that code.

I'd also like to include Uncle Bob's SOLID metrics and some of the Chidamber and Kemerer OO metrics. The hard part is finding tools to generate these for C++. The only option seems to be Krakatau Essential Metrics (I have no objection to paying for tools). My desire to use the CK metrics comes partly from the books Object-Oriented Metrics:Measures of Complexity by Henderson-Sellers and the earlier Object-Oriented Software Metrics.

If we start using a number of these metrics we could end up with ten or so numbers that are varying across time. I'm fairly ignorant of statistics but it seems it could be interesting to track a bunch of such metrics and then pay attention to which ones tend to vary.

Note that a related question is about measuring code quality across a large code base. I'm more interested in measuring the change.

+1  A: 

I'd consider using a Kiviat Diagram to represent multiple software metrics dimensions evolving over time. These diagrams represent multiple data points in a concave hull around a centerpoint. Visual inspection will show where a particular metric is going up or down, and one ought to be able to compute an overall ratio of area biased by metric value using some hueristic area computation.

Ira Baxter
Thanks, that was the magic term I needed to be able to narrow down my searches. I found a really interesting poster paper on using 3D Kiviat diagrams http://w3.msi.vxu.se/~kerren/pubs/kerren-softvis10.pdf
Andy Dent
+1  A: 

You can also have a glance at NDepend documentation about code metrics

http://www.ndepend.com/Metrics.aspx

Also with NDepend you can write Code query Language rules to detect refactoring and new methods/classes that are getting poor quality:

WARN IF Count > 0 IN SELECT METHODS WHERE (WasAdded OR CodeWasChanged) AND CyclomaticComplexity > 15

Finally NDepend lets visualize code metrics through interactive treemap:

http://www.ndepend.com/Doc_Treemap.aspx

alt text

Patrick Smacchia - NDepend dev
Thanks for the suggestion but as I said in the question, most of the code I'm concerned with is C++. I've seen jealousy-inducing demos of NDepend. I do appreciate the tip to look at their metrics documentation.
Andy Dent
Then why not using CppDepend? http://www.cppdepend.com/ The C++ version of NDepend?
Patrick Smacchia - NDepend dev