Netbeans 7.4 引入了“最多 10 行"每个方法规则.这个规则从何而来? [英] Netbeans 7.4 introduces "10 lines max" per method rule. Where does this rule come from?

查看:18
本文介绍了Netbeans 7.4 引入了“最多 10 行"每个方法规则.这个规则从何而来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NetBeans 7.4 beta 目前可供公众下载,它默认引入了一个奇怪的警告规则:

NetBeans 7.4 beta is currently available for public download, and it introduces a weird warning rule by default:

方法长度为 16 行(允许 10 行)

Method length is 16 lines (10 allowed)

我的问题是:这是公认的代码约定规则,可以在某处以某种方式证明吗?NetBeans 支持/开发人员说这不是错误,但没有说明为什么他们只允许 10 行,以及这条规则的确切起源.

My question is: Is this an accepted code convention rule, that can be proven somehow, somewhere ? NetBeans support/devs say it's not a bug, but don't give a statement why they only allow 10 lines, and where exactly this rule has its origin.

推荐答案

您可以在 NetBeans 选项中更改最大方法/函数长度警告行为(它位于 Tools->Options->Editor 下,在提示选项卡,在复选框列表中的行过多"部分下).

You can change the maximum method/function length warning behavior in NetBeans options (it's under Tools->Options->Editor, in the Hints tab, under "Too Many Lines" section in the checkboxes list).

您可以在那里设置最大行数、您希望如何收到警告等.

There you can set the maximum number of lines, how you would like to be warned, etc.

我相信该规则是由 NetBeans 开发人员引入的,因为在团队中工作时,QA 用来检查"代码标记长方法声明/函数体的自动化工具.不幸的是,代码分析师"对自动化工具的使用正在增加,而他们对背后原因的理解仍然有限.我并不是说你的函数应该有数百行长——这完全是错误的,而是一个硬编码的数字作为编码法则——来吧!

I believe that the rule was introduced by NetBeans developers because when working in teams, the automated tools that QAs use to "inspect" code flag long method declarations/functions bodies. Unfortunately, the use of automated tools by "code analysts" is on the rise, whilst their understanding of the reasons behind that are still limited. I do not say that your functions should be hundreds of lines long - that's just plain wrong, but a hard-coded number as a coding law - come on!

这篇关于Netbeans 7.4 引入了“最多 10 行"每个方法规则.这个规则从何而来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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