Java Compliance
Violations
Avoid
dead store to local variable.
Avoid
dead store of null to local variable.
Avoid unused imports.
Avoid
unused variables and private methods.
Method names, Member names, Local Variable
names must start with small case and remaining
words first letter must be capital. All letters of constant names must be capital.
words first letter must be capital. All letters of constant names must be capital.
If Else statements and For loops must
contain braces even for a single line also.
Avoid method
uses the same code for two branches (Like if and else both containing same
code)
Avoid Method
concatenates strings using + in a loop (Use StringBuffer or StringBuilder
instead)
Avoid
Duplicate Literals
Avoid
Unnecessary Local before Return
Avoid
Empty If else blocks
Avoid
Magic Number
Avoid
Possible null pointer deference
Avoid Method
call passes null for non null parameter
Modifier
order (Should follow public/protected/private, abstract, static, final,
transient, volatile, synchronised, native, strictfp)
Preserve the actual exception object
always as shown below
catch (Exception exception) {
log.error("AbcImpl - testmethod-" +exception.getMessage());
UserDefinedException userException
= new UserDefinedException("AbcImpl
- testmethod-" + exception.getMessage(), exception);
throw userException;
}
Performance :
Avoid using nested loops - for, while , do-while
Avoid creating string literals and try to use string builder and string buffer objects
Avoid recursive calls of functions
Avoid creating collection objects under loops - like list, set, map and queue
First clear the collection before re-setting the collection, otherwise for large amount of data case it
it appends all ways to existing object and then
collection occupies maximum memory and it leads to memory leak and
Avoid using nested loops - for, while , do-while
Avoid creating string literals and try to use string builder and string buffer objects
Avoid recursive calls of functions
Avoid creating collection objects under loops - like list, set, map and queue
First clear the collection before re-setting the collection, otherwise for large amount of data case it
it appends all ways to existing object and then
collection occupies maximum memory and it leads to memory leak and
it would not reset that collection.
No comments:
Post a Comment