Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

You can also have a glance at NDepend documentation about code metrics. Disclaimer: I am one of the developer of the tool NDepend.

With the Code Rule and Query over LINQ (CQLinq) facility, it is possible to ask for code metric evolution/trending across two different snapshots in time of the code base. For example there is a default rule proposed: Avoid making complex methods even more complex illustrated by the screenshot below:

Avoid making complex methods even more complex

Several metric trending rules are proposed like:

Concerning the visualization of code metric, NDepend lets visualize code metrics values through an interactive treemap:

Code Metric viualized through Treemap

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top