【发布时间】:2011-04-30 18:02:43
【问题描述】:
Checkstyle 说:
Class should define a constructor.
PMD 说:
Avoid unnecessary constructors - the compiler will generate these for you.
谁是对的?或者让我们这样说 - 在类中使用空的默认 ctor 有什么优缺点?
【问题讨论】:
-
这只是风格问题。生成的代码是一样的。
-
有趣的是,这两种观点已经在工具之间切换了位置...... PMD 现在敦促您使用默认构造函数,而 Checkstyle 不再关心了。
标签: java checkstyle pmd default-constructor