每个包多少个类?每个类的方法?每个方法行数? [英] how many classes per package? methods per class? lines per method?

查看:129
本文介绍了每个包多少个类?每个类的方法?每个方法行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须对一个大型Java项目做一个一般性的说明,但是我对它的了解很少,我想知道是否有确定以下内容的准则:

  • 可以认为每个软件包有多少个正确,低或高的类数(该项目每个软件包有3.89个类,对我来说似乎太小了),
  • 每个类中有多少方法? (该项目每个类有6.54个方法... 每个方法的行数是多少? (该项目每种方法大约有7行(对我来说似乎不错,也许有点低))

我应该注意,这个问题仅涉及体积.我有很多来自质量工具(checkstyle,jdepend,cpd,pmd,ncss)的报告,这些报告使我对代码冗余,类使用,错误等有了更多的了解.

解决方案

史蒂夫·麦康奈尔(Steve McConnell)在他的《代码完成》一书中建议每个类大约有7种方法,并且该方法中没有更多行,因此无需滚动即可在单个屏幕中查看. >

我不确定每个软件包的类.

我强烈建议阅读Code Complete,以获取有关此类主题的更多信息.

I have to give a general note to some huge Java project for which I have but little visibility and I was wondering if there were any guidelines for determining:

  • what number of classes per package can be considered right, to low, or to high (this project has 3.89 classes per package, which seems a bit too small for me),
  • number of methods per class? (this project has 6.54 methods per class...
  • number of lines per method? (this project has about 7 lines per method (seems pretty good to me, maybe a bit low))

I should note that this question is only dealing with volumetry. I have a bunch of reports from quality tools (checkstyle, jdepend, cpd, pmd, ncss) that give me more vision about code redundancy, classes usage, bugs, etc.

解决方案

Steve McConnell in his book Code Complete recommends about 7 methods per class and no more lines in a method then can be viewed in a single screen without scrolling.

I'm not sure about classes per package.

I would highly recommend reading Code Complete for more information on such topics.

这篇关于每个包多少个类?每个类的方法?每个方法行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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