Search This Blog

Saturday, May 30, 2009

Coding Standards - Part IV

Error and Exception Handling

Does the code avoid catching Exception (as opposed to more specific exception types)?
Does the code avoid throwing an explicit Exception object?

Does the code avoid having empty catch blocks?

Do methods check for null / empty arguments using Asserts in the Service Layer?
public void identifyUnadjustableCharges(List chargesDetails) {
Assert.notNull(chargesDetails,""Charges detail cannot be null."");
Assert.notEmpty(chargesDetails,""Charges detail cannot be empty."");"

Does the code use logging instead of System.out.println() or Throwable.printStackTrace()?

Are log types (fatal, error, warn, info, debug and trace) used appropriately?

Comment Rules
Is the amount of commenting appropriate?
A good rule of thumb is a ratio of comments to code of about 20-25%.
Commenting just for the sake of commenting should be avoided.

Are all date comments in the format YYYY/MM/DD?

Are all class members commented except for getters/setters?

Unit Test

Do test cases use meaningful Input combinations?
Include boundary conditions and invalid conditions. Null inputs has to be tested

Do test cases adequately cover functionality?
Test should exercise most of branches.80% code coverage is a good rule-of-thumb.
Is every method tested?
Simple getters and setters can be exempted.

Are all test cases independent of one another?

Is all test code under test folder?

No comments: