[racket] code metrics

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Wed May 30 03:07:25 EDT 2012

There is some code coverage instrumentation in the "errortrace" library, 
and I believe the DrRacket has some kind of coverage feature.

The other metrics you mention are very easy to get.  How useful they are 
is a different question, and depends on why you're asking.

Aside: code metrics are of course useful for convincing managers of things:

WRONG: "We've been making steady progress on functionality and QA, and 
the schedule feels tighter than last month, but people have been staying 
late, we're still on track for our weekly milestones, and morale is 
still pretty good.  We just don't have wiggle room to absorb any more 
surprises without slipping."

RIGHT: Ensure that the line count increases monotonically, whether or 
not that's good practice. "We have been producing average 9,876 new 
lines of code a day, and so are on track to our milestone of 300,000 new 
lines by the end of Q2."

WRONG: "We think it would take our best available developer more than a 
month to develop that functionality, but Acme has a component that does 
exactly what we need and that we think will be very quick to integrate."

RIGHT: "Acme answered our inquiry that their off-the-shelf component has 
40,000 SLOC of code, so if we multiply that by our cost metric of 12.3 
cents per SLOC, the Acme $3,000 royalty-free license gives us a cost 
savings of $1,920."

WRONG: "Everyone on the team is saying that the bit-rotted old library 
is slowing us down, and we think that Jim spending a couple days 
refactoring it in a few specific ways that he identified would be an 
immediate big win."

RIGHT: "Thanks to the software metrics tiger team that I led, we've 
learned that three of the key functions in the old library have McCabe 
cyclomatic complexity over 100, which, gentlemen, we all know is bad.  I 
propose we task some resources to cut that in half, which we all know is 
better.  In fact, I have a new initiative to boost productivity by 
simplifying our code and bringing this number down to 10.  Heck, why be 
followers when we can be leaders: we're going to five blades."

Neil V.

Posted on the users mailing list.