代码行数:包括删除的行吗?

发布于 2024-10-19 01:12:33 字数 62 浏览 7 评论 0原文

在获取指标时,我们是否需要考虑删除的代码行以及插入(添加)/修改的代码行? (说代码修订让我删除了一些代码行)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

各自安好 2024-10-26 01:12:33

这实际上取决于指标想要显示的内容。

就个人而言,我在删除代码后总是比添加代码后更沾沾自喜和自我满足。但我从来没有发现“代码行数”最终成为一个特别有用的指标。请注意您对此类数字的重视程度。

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.

信仰 2024-10-26 01:12:33

LOC 很少与代码质量相关,而代码质量才是您应该衡量的。

如果我要求编写一个函数来反转链表,那么什么可能是更好的解决方案?一个单行代码读起来就像我把头敲在键盘上,但有效(Perl,我看着你......),还是一个 100 行代码,深入到令人难以忍受的细节以明确地逐步完成所有内容?

或者介于两者之间?

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?

戒ㄋ 2024-10-26 01:12:33

使用 SLOC(软件代码行数)作为指标的问题在于,它很容易被欺骗:

if( condition ){
    return 1;
}
return 2;

那是 4 行,但是……

if( condition )
{
    return 1;
}
else
{
    return 2;
}

嗯,那是 8 行。那么您的雇主或客户试图如何处理这些数据呢?它真正告诉了他们多少信息?有很多比 SLOC 更好的指标。

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.

唔猫 2024-10-26 01:12:33

是的。如果您认为行数很重要,则删除的行数也很重要。

但这引出了一个问题:您将如何利用这些行数。我当然希望你不要说行数最多的人效率最高。这当然不是真的。事实上,如果你明确表明人们正在根据他们提交的行数进行评估,那么你只会鼓励人们做一些事情来增加他们的提交行数。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文