Search This Blog

Saturday, May 30, 2009

Coding Standards - Part II

Naming: (mostly covered by checkstyle)

Are class, variable, and method names descriptive?
Like Other than following naming convention, all names should be descriptive

Coding Standard


Is the code self-descriptive and easily understood?
Like Code should be self-descriptive and logically paragraphed.If a reviewer can not get general idea of a method in 30 seconds,
either the design or the comments should be updated

Does the code use if/else for mutually exclusive conditions rather than if/if?
like avoid using flat if while nested conditionals are more accurate

When comparing a constant with a variable, is the constant's equals() method used?
like Avoid null object reference

Are static final String constants used instead of string literals?

Is StringBuilder used instead of appending Strings?

Is StringBuilder used instead of StringBuffer?

Are JDK 1.5 enhanced for loops used instead of using index on collections?

Does the code use equals() instead of comparing references (==||!=)?

Does the code check instanceof before a casting?

Does the code check for null before accessing an object?

Does the code use Spring for resource access?

Are variables declared using an interface when available rather than a class?

Does the code avoid making assignments to loop iterator variables?

Assignment to loop variable makes the code difficult to read and maintain

Does the code avoid using unnecessary return statements?

Will all loops terminate whether or not an exception occurs?

No comments: