Archive
Code Insights
-
Avoid binary operators with identical members
Using the same value on either side of a binary operator is almost always a mistake. In the case of logical operators, it is…
-
Avoid ‘if/else if’ & cases statements having the same condition
A chain of if/else if statements is evaluated from top to bottom. At most, only one branch will be executed: the first one with…
-
Avoid dead code
Dead code are instructions that can never be reached. Obvious dead code are instructions that follow unconditional jumps in the same statement block. Dead…
-
Avoid βif … else ifβ constructs with missing final βelseβ clauses
This rule applies whenever an if statement is followed by one or more else if statements; the final else if should be followed by…
-
Increment (++) and decrement (–) operators should not be used in a method call or mixed with other operators in an expression
The use of increment and decrement operators in method calls or in combination with other arithmetic operators is not recommended
-
‘switch’ statements should not be nested
Nested switch structures are difficult to understand because you can easily confuse the cases of an inner switch as belonging to an outer statement.…
-
Avoid collapsible nested ‘if’
Merging collapsible if statements increases the codeβs readability.
-
The code contains one or more “with” instructions
The with statement in javascript inserts an object at the front scope chain, so any property/variable references will first try to be resolved against…
-
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…
-
The code contains at least one class defining a destructor
For several reasons detailed in references, using finalizers is not recommended.