开发者

CCN java function- is there any guide line on what could be realistic limit

I am using javancss to detect CCN of methods. There are methods in our source code with values varying from 1 to 35 (are are even large).

Is there any guide line on开发者_如何学运维 what could be realistic limit? The article here gives some ideas -- http://java-metrics.com/cyclomatic-complexity/cyclomatic-complexity-what-is-it-and-why-should-you-care

I am thinking of 10 as soft limit and 15 as hard limit.. Main reason is that testing gets complicated with larger values..

I would like to hear from SO community..


I have two methods I use:

  1. Pick a maximum value and stick to it (mine is 10).
  2. Just regularly review your code and fix the method with the highest score.

Another method to use is to be very rigorous when fixing bugs - check back with source control to see which methods changed to fix the bug. Refactor those methods to reduce their complexity.


As also mentioned in your link paper I think the most important aspect is that you don't see the limit of 10 or 15 as a hard limit, but always give a good justification if the limit is exceeded. In that way you're ''forced'' to carefully examine critical methods and check if is really necessary that they are this complex.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜