Should we need to consider deleted lines of code , along with inserted(added)/modified lines of code while taking metrics? ( say revision's to code made me to delete some lines of code)
Countlines of code : include deleted lines?
388 views Asked by srinannapa AtThere are 4 answers
LOC is rarely correlated with quality of code, which is what you should be measuring.
If im asked to write a function to, say, reverse a linked list, then whats likely to be a better solution? A one liner that reads like I mashed my head on the keyboard, but works (Perl, im looking at you...), or a 100 liner that goes into excriuciating detail to explicitly step through everything?
Or somewhere inbetween?
The problem with using SLOC (software lines of code) as a metric is that it can be gamed easily:
if( condition ){
return 1;
}
return 2;
That's 4 lines but...
if( condition )
{
return 1;
}
else
{
return 2;
}
Well, that's 8 lines. So what are your employers or customers trying to do with the data? How much does it really tell them? There are a bunch of much better metrics to be had than SLOC.
Yes. The number of lines deleted is significant if you consider line counts significant.
But that begs the question of what use you are going to make of these line counts. I certainly hope that you don't say that the person with the largest line counts is the most productive. That certainly isn't true. Indeed, if you make it clear that people are being assessed on the number of lines they commit, you only encourage people to do things to inflate their commit line counts.
That really depends on what the metrics are trying to show.
Personally I'm always more smug and self-satisfied after deleting code than after adding it. But then I've never found that "lines of code" ends up as a particularly useful metric in the first place. Be careful of what importance you place on such a figure.