Archive
Programming Best Practices
-
The code contains too many data contigus levels
When creating a new data level, do not add 1 to the previous level. Having not contigus level is easier for inserting an intermediate…
-
Errors should not be created without being thrown
Creating a new Error without actually throwing it is useless and is probably due to a mistake.
-
Avoid structures initializations with unamed fields
You should almost always specify field names when initializing structs. This is now enforced by go vet.
-
Avoid self-assigned variables
There is no reason to re-assign a variable to itself. Either this statement is redundant and should be removed, or the re-assignment is a…
-
The code contains inner functions
While most script engines support Function Declarations within blocks it is not part of ECMAScript (see ECMA-262, clause 13 and 14). Worse implementations are…
-
Avoid using ellipsis in functions
Functions should not be defined with a variable number of arguments. Varargs methods are a convenient way to define methods that require a variable…
-
Avoid Equals methods not testing their parameters
Because the equals method takes a generic Object as a parameter, any type of object may be passed to it. The method should not…
-
The code contains classes that overload equals(Object)
βequalsβ as a method name should be used exclusively to override Object.equals(Object) to prevent any confusion. It is tempting to overload the method to…
-
Avoid equality in loop termination condition
Testing for loop termination using an equality operator (== and !=) is dangerous, because it could set up an infinite loop. Using a broader…
-
Avoid using ellipsis in functions
Functions should not be defined with a variable number of arguments. Varargs methods are a convenient way to define methods that require a variable…