一份我们团队Java开发的开发规范,参考了阿里巴巴Java开发手册终极版v1.3.0
編程規約
space in comment:
bad example:
Suggestion: 與其“半吊子”英文來注釋,不如用中文注釋把問題說清楚。專有名詞與關鍵字保持英文原文即可。
謹慎注釋掉代碼。在上方詳細說明,而不是簡單地注釋掉。如果無用,則刪除。 說明:代碼被注釋掉有兩種可能性:1)后續會恢復此段代碼邏輯。2)永久不用。前者如果沒有備注信息,難以知曉注釋動機。后者建議直接刪掉(代碼倉庫保存了歷史代碼)。
Do not mix production code with test code. All testing codes must be put to folder src\test\java.
Constant:
For boolean variable in POJO, no “is” prefix is allowed.
Always use meaningful naming for self-descriptive purpose.
Bad example: no prefix for local variable.
bad example:
space between method and argument:
bad example:
guideline:
bad example:
IDE text file encoding: UTF-8; IDE new line format: use Unix instead of Windows
IDE setting:
why we should set this property
No business logic is allowed in constructor. If initialization logic is needed, put it in init().
class method sequence
public method > protected > private > getter / setter
Bad example:
if (condition) statements;Better to use if XXX return; instead of if XXX else YYY:
參考文檔
阿里巴巴Java開發手冊終極版v1.3.0
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的一份我们团队Java开发的开发规范,参考了阿里巴巴Java开发手册终极版v1.3.0的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 荒野大镖客2死神之眼怎么用?荒野大镖客2
- 下一篇: wikioi 2573 大顶堆与小顶堆并