How can I visualize changes in a large code base quality?
Asked Answered
P

3

7

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.

Padriac answered 6/10, 2010 at 6:18 Comment(0)
L
3

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.

Lumberyard answered 13/10, 2010 at 4:21 Comment(2)
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 w3.msi.vxu.se/~kerren/pubs/kerren-softvis10.pdfPadriac
Updating the link to the paper: homepage.lnu.se/staff/akemsi/pubs/kerren-softvis10.pdfGimel
E
1

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

Ewens answered 18/10, 2010 at 17:7 Comment(4)
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.Padriac
Then why not using CppDepend? cppdepend.com The C++ version of NDepend?Ewens
I hadn't noticed it existed. The only mention is down in the bottom right corner of the home page "below the fold" and NDepend is advertised heavily as a .Net tool. I will certainly give it a trial. I also suggest you talk to the marketing folks about getting a mention on the website banner to say you also do C++ and Java - I wonder how many others missed the C++ link. ThanksPadriac
I did end up buying and using CppDepend for a while but had to discontinue it on this code base as some of the complex dispatching logic made CppDepend fail to follow call chains. To be fair, the dispatching is very dynamic - the code is a large "platform-like" CAD system with a scripted GUI and extension points for user scripting.Padriac
E
0

There is a fresh approach for this topic. E.g. enter image description here https://github.com/databricks/koalas/pull/840#issuecomment-536949320

See https://softagram.com/docs/visualizing-code-changes/ for more info or do an image search in search engine using the two keywords: softagram koalas

Disclaimer: I work for Softagram.

Ernieernst answered 5/10, 2020 at 20:7 Comment(1)
This doesn't seem relevant to the original (old) question. I wasn't asking about just "change" but change in qualityPadriac

© 2022 - 2024 — McMap. All rights reserved.