开发者

Countlines of code : include deleted lines?

开发者 https://www.devze.com 2023-02-13 04:06 出处:网络
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 ma开发者_开发问答de me to delete some lines of code

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 ma开发者_开发问答de me to delete some lines of code)


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消