TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
 
TIOBE - Java Coding Standard
Search

Category: Design

Synopsis:The Design Ruleset contains a collection of rules that find questionable designs.


Description:
The Design Ruleset contains a collection of rules that find questionable designs.

Coding Rules

NameCheckedSynopsis
Design1 Checked automatically with code checker Classes with only static methods should have a private constructor
Design2 Checked automatically with code checker Avoid unnecessary if..then..else statements when returning a boolean
Design3 Checked automatically with code checker Avoid unnecessary comparisons in boolean expressions
Design4 Switch statements should have a default label
Design5 Checked automatically with code checker Deeply nested if..then statements are hard to read
Design6 Checked automatically with code checker Avoid reassigning parameters
Design7 Checked automatically with code checker A high ratio of statements to labels in a switch statement. Consider refactoring
Design8 Checked automatically with code checker Don't call overridable methods during object construction
Design9 Checked automatically with code checker Avoid instantiation through private constructors from outside of the constructor's class
Design10 Checked automatically with code checker This final field could be made static
Design11 Checked automatically with code checker Ensure that resources are closed after use
Design12 Checked automatically with code checker Non-static initializers are confusing
Design13 Checked automatically with code checker The default label should be the last label in a switch statement
Design14 Checked automatically with code checker A non-case label was present in a switch statement
Design15 Checked automatically with code checker This call to Collection.toArray() may be optimizable
Design16 Checked automatically with code checker Avoid equality comparisons with Double.NaN
Design17 Checked automatically with code checker Avoid using equals() to compare against null
Design18 Checked automatically with code checker Avoid if (x != y) ..; else ..;
Design19 Checked automatically with code checker Avoid instantiating an object just to call getClass() on it; use the .class public member instead
Design20 Checked automatically with code checker Avoid idempotent operations (like assigning a variable to itself)
Design21 Checked automatically with code checker When instantiating a SimpleDateFormat object, specify a Locale
Design22 Checked automatically with code checker Declare private fields final, if possible
Design23 Checked automatically with code checker When doing a String.toLowerCase()/toUpperCase() call, use a Locale
Design24 Checked automatically with code checker Avoid protected fields in a final class. Change to private or package access
Design25 Checked automatically with code checker Possible unsafe assignment to a non-final static field in a constructor
Design26 Checked automatically with code checker Class cannot be instantiated and does not provide any static methods or fields
Design27 Checked automatically with code checker Use block level rather than method level synchronization
Design28 Checked automatically with code checker A switch statement does not contain a break
Design29 Checked automatically with code checker Call Thread.notifyAll() rather than Thread.notify()
Design30 Checked automatically with code checker An instanceof check is being performed on the caught exception. Create a separate catch clause for this exception type
Design31 Checked automatically with code checker This abstract class does not have any abstract methods
Design32 Checked automatically with code checker No need to check for null before an instanceof
Design33 Use equals() to compare object references
Design34 Checked automatically with code checker Position literals first in String comparisons
Design35 Checked automatically with code checker Consider simply returning values instead of storing it in a local variable
Design36 Checked automatically with code checker Singleton is not thread safe
Design37 Checked automatically with code checker Document empty method
Design38 Checked automatically with code checker Document empty constructor
Design39 Checked automatically with code checker An Interface should be used only to model a behaviour; consider converting this to a class
Design40 Checked automatically with code checker Static java.text.Format objects should be accessed in a synchronized manner
Design41 Checked automatically with code checker Caught exception is rethrown, original stack trace may be lost
Design42 Checked automatically with code checker Substitute calls to size() == 0 (or size() != 0) with calls to isEmpty()
Design43 Checked automatically with code checker Declare members privately
Design44 Checked automatically with code checker Never initialize a final field to null
Design45 Checked automatically with code checker Avoid overloading the getInstance method
Design100 Checked automatically with code checker The scope of local variables should be kept to a minimum.
Design101 Checked automatically with code checker Classes with only private constructors should be declared as final