代码是一种艺术
来源:互联网 发布:java实现文件下载 编辑:程序博客网 时间:2024/04/29 20:02
今天偶然看到下面几行代码,我觉得写得可以,所以记录下来。
1,注释很全。
2,代码质量可以。addMesage方法中使用Assert.notNull进行验证是否为空,若异常则抛出RuntimeException。(这种方式不适用国际化)
3,logger.isDebugEnabled 使用Log4j,查看是否开启debug。
3,代码格式,间隔很漂亮。
/** * Associate the given message with the given code. * @param code the lookup code * @param locale the locale that the message should be found within * @param msg the message associated with this lookup code */public void addMessage(String code, Locale locale, String msg) {Assert.notNull(code, "Code must not be null"); Assert.notNull(locale, "Locale must not be null");Assert.notNull(msg, "Message must not be null");this.messages.put(code + "_" + locale.toString(), msg);if (logger.isDebugEnabled()) {logger.debug("Added message [" + msg + "] for code [" + code + "] and Locale [" + locale + "]");}}
0 0
- 代码是一种艺术
- 思念是一种艺术
- 管理是一种艺术
- 妥协是一种艺术
- “分而治之”是一种艺术
- 架构是一种平衡艺术
- 领导力是一种艺术
- 代码是一项艺术
- 编程是一种艺术,做优秀的代码工匠--读《编程匠艺》有感
- UML 学习笔记------ 建模是一种艺术
- 编程是一种“组合的艺术”
- 编程是一种“组合的艺术”
- 李开复:领导力是一种独特艺术
- :婚姻是一种妥协的艺术
- 乐又是一种听觉艺术
- 平和是一种修炼和一种人生的艺术
- 调试代码是一种乐趣
- 判断可能人选的销售天分是一种艺术
- myeclipse tomcat add deployment 点击无反应
- 成为高手,人人可以
- HDOJ 2988 -------最小生成树
- 手机用户操作系统喜好分析
- Valid Parentheses 括号配对
- 代码是一种艺术
- python文件、存储、压缩
- setTimeout函数
- JSTL不同版本和EL表达式的关联
- Android EditText/TextView使用SpannableString显示复合文本
- MFC常用类:定时器Timer
- Java反射 获取某个类的属性值、字段名、注解等常用代码
- 湛江中医治疗慢性鼻炎秘方
- python gzip模块实现文件压缩的方法