One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king . Professional use their powers for good and write code that others can understand.
Use Intention-Revealing names 表明意图
int d; –> int daysSinceCreation;
list1 –> flaggedCells
Avoid Disinformation 提供真实信息
accountList: Unless it’s actually a List. otherwise, accountGroup/bunchOfAccounts/accounts would be better
Make meaningful distinctions 有意义的区分
copyChars(a1, a2) –> copyChars(source, destination)
Use Pronounceable Names 使用可以发音的变量名称
luo –> lastUpdatedOn
Hungarian notation 匈牙利命名法 不必再刻意添加前缀
strName –> name
m_desc –> desc
Class names: noun or noun phrase. Method names, verb or verb phrase.
Don’t be cute 清晰表达即可, 不要画蛇添足
eatMyShorts() –> abort() [Eat my shorts, by Bart Simpson]
Pick One Word per Concept 为一个概念选定一个名称 Don’t pun 不要使用双关词汇
Use Solution Domain Names 使用解决方案领域内词汇
Add Meaningful Context 有意义的语境, Don’t Add Gratuitous Context 但不要增加无意义的上下文
Class name: SGMailingAddress –> MailingAddressDevelopment Notes • Java; Tagged with: Clean Code • Java • Quality Control; @ May 2nd, 2013 22:04
Several Eclipse plugins which can help to improve code quality. all plugs can find from Eclipse Market.
Find potential bugs for you. “a program which uses static analysis to look for bugs in Java code”
“eCobertura is a free Eclipse plugin for Cobertura – a Java code coverage reporting tool.”
With “eCobertura”, we can get an overview of code coverage within Eclipse.
BTW, This plugin hasn’t been updated for more than 2 years.
Help developer to check the coding style, for example, coding conversation, make sure the code is clean and neat.
Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.
[to be continued]
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.