一份我们团队Java开发的开发规范,参考了阿里巴巴Java开发手册终极版v1.3.0

编程规约

  1. For variable name, always use English with lowerCamelCase.

space in comment:

bad example:

Suggestion: 与其“半吊子”英文来注释,不如用中文注释把问题说清楚。专有名词与关键字保持英文原文即可。

谨慎注释掉代码。在上方详细说明,而不是简单地注释掉。如果无用,则删除。 说明:代码被注释掉有两种可能性:1)后续会恢复此段代码逻辑。2)永久不用。前者如果没有备注信息,难以知晓注释动机。后者建议直接删掉(代码仓库保存了历史代码)。

  1. Do not mix production code with test code. All testing codes must be put to folder src\test\java.

  2. Constant:




  1. For boolean variable in POJO, no “is” prefix is allowed.

  2. Always use meaningful naming for self-descriptive purpose.

Bad example: no prefix for local variable.


  1. Naming per layer


  1. Bracket usage
if( XXX ){
	yyy;	
}

if( XXX ){
	yyy;
} else{
	
}

  1. space usage

bad example:

space between method and argument:

bad example:


  1. new line usage

guideline:

bad example:


  1. text file encoding

IDE text file encoding: UTF-8; IDE new line format: use Unix instead of Windows
IDE setting:

why we should set this property


  1. basic type and wrapper object


  1. No business logic is allowed in constructor. If initialization logic is needed, put it in init().

  2. class method sequence

public method > protected > private > getter / setter


  1. No business logic in setter/getter


  1. Bracket is mandatory in if/else/for/while/do.

Bad example:

if (condition) statements;

Better to use if XXX return; instead of if XXX else YYY:

参考文档

阿里巴巴Java开发手册终极版v1.3.0

更多Jerry的原创文章,尽在:“汪子熙”:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汪子熙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值