Java Inspection Checklist
o Are descriptive variable and constant
names used in accord with naming conventions?
o Are there variables or atributes with confusingly similar names?
o Is every variable and attribute correctly typed?
o Is every variable and attribute properly initialized?
o Could any non-local variables be made local?
o Are all for-loop control variables declared in the loop header?
o Are there literal constants that should be named constants?
o Are there variables or attributes that should be constants?
o Are there attributes that should be local variables?
o Do all attributes have appropriate access modifiers (private, protected, public)?
o Are there static attributes that should be non-static or vice-versa?
o Are descriptive method names used in
accord with naming conventions?
o Is every method parameter value checked before being used?
o For every method: Does it return the correct value at every method return point?
o Do all methods have appropriate access modifiers (private, protected, public)?
o Are there static methods that should be non-static or vice-versa?
o Does each class have appropriate
constructors and destructors?
o Do any subclasses have common members that should be in the superclass?
o Can the class inheritance hierarchy be simplified?
o For every array reference: Is each
subscript value within the defined bounds?
o For every object or array reference: Is the value certain to be non-null?
o Are there any computations with mixed
o Is overflow or underflow possible during a computation?
o For each expressions with more than one operator: Are the assumptions about order of evaluation and precedence correct?
o Are parentheses used to avoid ambiguity?
o For every boolean test: Is the correct
o Are the comparison operators correct?
o Has each boolean expression been simplified by driving negations inward?
o Is each boolean expression correct?
o Are there improper and unnoticed side-effects of a comparison?
o Has an "&" inadvertently been interchanged with a "&&" or a "|" for a "||"?
o For each loop: Is the best choice of
looping constructs used?
o Will all loops terminate?
o When there are multiple exits from a loop, is each exit necessary and handled properly?
o Does each switch statement have a default case?
o Are missing switch case break statements correct and marked with a comment?
o Do named break statements send control to the right place?
o Is the nesting of loops and branches too deep, and is it correct?
o Can any nested if statements be converted into a switch statement?
o Are null bodied control structures correct and marked with braces or comments?
o Are all exceptions handled appropriately?
o Does every method terminate?
o Have all files been opened before use?
o Are the attributes of the input object consistent with the use of the file?
o Have all files been closed after use?
o Are there spelling or grammatical errors in any text printed or displayed?
o Are all I/O exceptions handled in a reasonable way?
o Are the number, order, types, and
values of parameters in every method call in agreement with the called method's
o Do the values in units agree (e.g., inches versus yards)?
o If an object or array is passed, does it get changed, and changed correctly by the called method?
o Does every method, class, and file have
an appropriate header comment?
o Does every atribute, variable, and constant declaration have a comment?
o Is the underlying behavior of each method and class expressed in plain language?
o Is the header comment for each method and class consistent with the behavior of the method or class?
o Do the comments and code agree?
o Do the comments help in understanding the code?
o Are there enough comments in the code?
o Are there too many comments in the code?
o Is a standard indentation and layout
format used consistently?
o For each method: Is it no more than about 60 lines long?
o For each compile module: Is no more than about 600 lines long?
o Is there a low level of coupling
between modules (methods and classes)?
o Is there a high level of cohesion within each module (methods or class)?
o Is there repetitive code that could be replaced by a call to a method that provides the behavior of the repetitive code?
o Are the Java class libraries used where and when appropriate?
o Are arrays large enough?
o Are object and array references set to null once the object or array is no longer needed?
o Can better data structures or more
efficient algorithms be used?
o Are logical tests arranged such that the often successful and inexpensive tests precede the more expensive and less frequently successful tests?
o Can the cost of recomputing a value be reduced by computing it once and storing the results?
o Is every result that is computed and stored actually used?
o Can a computation be moved outside a loop?
o Are there tests within a loop that do not need to be done?
o Can a short loop be unrolled?
o Are there two loops operating on the same data that can be combined into one?
o Are frequently used variables declared register?
o Are short and commonly called methods declared inline?
Return to Home Page
Copyright 1999 Christopher Fox