什么代码指标让您相信所提供的代码是“蹩脚的"? [英] What code metric(s) convince you that provided code is "crappy"?

查看:18
本文介绍了什么代码指标让您相信所提供的代码是“蹩脚的"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个文件的代码行数、每个类的方法、圈复杂度等等.开发人员抵制并解决大多数(如果不是全部)!有一篇很好的 Joel 文章(现在没时间找).

Code lines per file, methods per class, cyclomatic complexity and so on. Developers resist and workaround most if not all of them! There is a good Joel article on it (no time to find it now).

您推荐使用什么代码指标来自动识别蹩脚代码"?

What code metric(s) you recommend for use to automatically identify "crappy code"?

什么最能说服(你不能说服我们所有人接受一些蹩脚的指标!:O))开发人员认为这段代码是垃圾".

What can convince most (you can't convince all of us to some crappy metric! :O) ) of developers that this code is "crap".

只有可以自动测量的指标才算数!

Only metrics that can be automatically measured counts!

推荐答案

没有关于编码风格的指标是此类警告的一部分.

No metrics regarding coding-style are part of such a warning.

对我来说,它是关于代码的静态分析,它可以真正一直开启":

For me it is about static analysis of the code, which can truly be 'on' all the time:

  • cyclomatic complexity (detected by checkstyle)
  • dependency cycle detection (through findbugs for instance)
  • critical errors detected by, for instance findbugs.

我会将覆盖测试放在第二步,因为此类测试可能需要时间.

I would put coverage test in a second step, as such tests can take time.

不要忘记蹩脚"代码不是由指标检测的,而是由组合进化检测到的(如趋势")指标:请参阅代码指标的魅力是什么?问题.

Do not forget that "crappy" code are not detected by metrics, but by the combination and evolution (as in "trend) of metrics: see the What is the fascination with code metrics? question.

这意味着您不仅要推荐代码指标来自动识别糟糕的代码"",还必须推荐正确的组合和趋势分析来遵循这些指标.

That means you do not have just to recommend code metrics to "automatically identify "crappy code"", but you also have to recommend the right combination and trend analysis to go along those metrics.

在旁注中,我确实分享了您的沮丧;),而且我不同意 tloach 的观点(在另一个答案的评论中)提出一个模糊的问题,得到一个模糊的答案"他说......你的问题应该得到一个具体的答案.

On a sidenote, I do share your frustration ;), and I do not share the point of view of tloach (in the comments of another answers) "Ask a vague question, get a vague answer" he says... your question deserve a specific answer.

这篇关于什么代码指标让您相信所提供的代码是“蹩脚的"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆