ISO/IEC/IEEE 24765:2010, Systems and software engineering—Vocabulary, defines reliability as the ability of a system or component to perform its required functions under stated conditions for a specified period of time [ISO/IEC/IEEE 24765:2010]. ISO/IEC 9126-1:2001, Software engineering—Product quality—Part 1: Quality model, provides a similar definition of reliability as the capability of the software product to maintain a specified level of performance when used under specified conditions [ISO/IEC 9126-1:2001].

Software reliability is an important factor affecting system reliability. It differs from hardware reliability in that it reflects design perfection, rather than manufacturing perfection. Wear or aging does not occur in software. Limitations in reliability are the results of faults in requirements, design, and implementation. Failures resulting from these faults depend on the way the software product is used and the pro- gram options selected rather than on elapsed time.

ISO/IEC/IEEE 24765:2010 defines software reliability as the probability that software will not cause the failure of a system for a specified time under specified conditions [ISO/IEC/IEEE 24765:2010]. The probability is a function not only of the inputs to and use of the system, but also of the existence of faults in the software. The inputs to the system determine whether existing faults, if any, are encountered. The high complexity of software is the major contributing factor to software reliability problems.

These guidelines deal with Java language features that can easily be misused by the unwary. The Java language allows a great deal of flexibility in the ways in which it is used, but some of these uses can lead to obscure techniques and code that is difficult to understand and maintain. By following these guidelines, programmers will produce code that is less prone to bugs and runtime failure.

This chapter includes guidelines that

  1. Help reduce errors, and are consequently important for developing reliable Java code
  2. Contain specific Java coding recommendations to improve software reliability

 

37. Do not shadow or obscure identifiers in subscopes
38. Do not declare more than one variable per declaration
39. Use meaningful symbolic constants to represent literal values in program logic
40. Properly encode relationships in constant definitions
41. Return an empty array or collection instead of a null value for methods that return an array or collection
42. Use exceptions only for exceptional conditions
43. Use a try-with-resources statement to safely handle closeable resources
44. Do not use assertions to verify the absence of runtime errors
45. Use the same type for the second and third operands in conditional expressions
46. Do not serialize direct handles to system resources
47. Prefer using iterators over enumerations
48. Do not use direct buffers for short-lived, infrequently used objects
49. Remove short-lived objects from long-lived container objects