Software Quality Inspection Checklist for Java Classes
Assignment 4, CISC 323, winter 2002
This checklist is intended to be used with Report of Findings for inspecting
and reporting on Java class definitions. It is organized by software
quality Criteria, according to the McCall model.
In the checklist, examples are given: they are not meant to be prescriptive,
only suggestive.
Inspection Instructions
-
Familiarize yourself with the code you are to inspect. Make sure
you understand generally how it is designed to work, and that there are
no passages of Java code which you do not recognize or understand at all.
If necessary, consult a Java manual.
-
Inspect the code for each checklist item in each category.
-
For a checklist item which requires code elements to have a certain property
(e.g. layout used consistently, algorithms to be space efficient),
make an entry in the Report of Findings if you discover an element which
doesn't
have the property. Indicate where in the project (by line number
and class name) you found the element.
-
For a checklist item which prohibits a code element (e.g.
calls to System.exit), make an entry in the Report of Findings
if you discover the element. Indicate where in the project you found
it.
-
For a checklist item which requires a code element to be present
(e.g. a method with a particular name), make an entry in the Report
of Findings if you discover that the element is absent. Indicate
the class or method header (by line number) in which the element ought
to have appeared.
Quality Criteria and Inspection Items.
-
Consistency (of layout, name choice, and code organization)
-
Placement of braces ({ and }) done consistently throughout.
-
Indentation is used, consistently, to indicate block structure within braces.
-
Block comments precede the code they describe.
-
The same names or abbreviations are used consistently for the same concept
(e.g. not next, nextNode, and nxtn in
three places in the same class).
-
Naming conventions for classes, class members (methods and variables),
constants, and local variables, are distinct and consistent (e.g.ClassName,
classMethod,
CLASS_CONSTANT, and
local_variable).
-
Anomaly Management (of inputs and contexts
which the requirements didn't anticipate)
-
Input parameters to public methods, and inputs read from files, are checked
explicitly for all unacceptable values.
-
Unacceptable public input produces error output and/or throws exceptions.
-
Unacceptable public input produces a documented result (e.g. zero,
null, the empty String ...) when there is no exception thrown.
-
Input parameters to private methods are assumed acceptable and are not
checked.
-
Efficient Processing (using as little processing
time as is reasonable)
-
Loops contain complex code, or other loops, only when necessary.
-
Array processing (especially search) contains loop exit code to execute
when the condition is found.
-
Efficient Storage
-
All local and instance variables are actually used somewhere.
-
Simplicity
-
No method is longer than one page (about 60 lines including comments).
-
Math expressions, control expressions (in ifs, whiles, fors, and switches)
are as simple as possible.
-
Little private methods are preferred to repeating the same code over and
over in different places.
-
Self-Description
-
Comments are provided whenever the purpose or reason for doing something
in the code is obscure.
-
Comments are provided to describe every method, however briefly.
-
Comments are provided to describe the purpose, restrictions, and relationships
between all instance variables in a class.
-
All names are chosen well and consistently to reflect their usage and purpose.
-
Constants (static final) are used instead of magic numbers. (e.g.
Don't write 42, write static final ULT_ANS = 42; and
then use ULT_ANS instead.)
-
Booleans are not compared to boolean constants. (e.g. if (!found)
is preferred to if (found == false)).
-
Modularity
-
Instance variables are not public.
-
Variables are declared as locally as possible.
-
Public method headers don't reveal the internal design of the class.
-
System.exit is not called directly.
-
Instrumentation
-
Every class has a parameterless toString method which returns
a String containing a dump or summary of an instance of the class.
This checklist was developed for ELEC 372, winter 2001, and is reproduced
here with only a few small changes.