1.原则
- 单一职责原则.
- 开放封闭原则.
- 依赖倒置原则.
- 接口隔离原则.
- 里氏代换原则.
2.工具
3.健壮性
3.1 避免NPE(NullPointException) 允许为null的变量,在使用前要判断是否为空(参见effective java),可以用findbug检测到
建议短路表达式
if (member == null || member.getName().equals("myname")) {
}
建议用stringUtil判断为空
if (StringUtil.isEmpty(str)) {
}
建议把常量放在前面
if ("myconstant".equals(str)) { // 而不是str.equals("myconstant")
}
3.2 Serializable object;
3.3 clean resource at finally .