Small class/function
Don't use boolean/flag params
Don’t repeat yourself
- don't copy/paste, refactor it
Do only one thing
counter example: !isNotRemeberMe -> isRemeberMe
Don't use magic numbers/strings
- use constant, enum
Follow code standard.
Don't use boolean/flag params
Don’t repeat yourself
- don't copy/paste, refactor it
Do only one thing
counter example: !isNotRemeberMe -> isRemeberMe
Don't use magic numbers/strings
- use constant, enum
Follow code standard.
Follow common code patterns
Familiar with common code bug patterns, and beware of them when write code.
Designing the code, adhere to common design principles.
Improve code readability
Comment non-trivial method and class.
Comment not just how the code work, but also why it works that way.
Document every fix and change and the decision behind it.
Rerunable Unit test is essential to find code breakage early.
Automated test and use continuous integration tool such as Cruise Control to automate test whenever new code is committed.
Use static source code analysis tool - such as findBug, PMD and check style to find code bugs.
Self code review
Team code review
Let the originator explain the design, the cause of the change, explain the code, and how it is unit tested, and whether it is thorough tested.
Except the correctness of code logic and function, also check code comment, and readability.
Logging
Every application may have bug, for any production application, having complete logging is important to find root cause of bug and fix it.
Using proven code
Use Regression testing to find code breakage.
Dedicated testers