Archive
Product
-
Boolean checks should not be inverted
is needlessly complex to invert the result of a boolean comparison. The opposite comparison should be made instead. This is furthermore the case in…
-
Avoid using multiple labeled returns in lambda expression
The return keyword is relative to the nearest enclosing function (or anonymous function). So for returning from lambda, a labeled return is needed. But…
-
Avoid generic catch
You should not ignore exceptions. It can be tempting to be lazy when catching exceptions and do something like this: (see example below).
-
Use Elvis operator to avoid unclear syntax pattern
Elvis operator ?: is an syntactic sugar for if (!x) { x=something }. Prefer Elvis notation for readability considerations.
-
Avoid undefined type on data or routines declaration
Groovy support dynamic types, that is declarations where the type is def or unspecified.
-
Avoid to update static fields from instance methods
Correctly updating a static field from a non-static method is tricky to get right and could easily lead to bugs if there are multiple…
-
Avoid to update parameters inside routine’s bodies
Reassigning parameter of function to a new value within the body of the method/closure, is a confusing and questionable practice. Use a temporary variable…
-
Avoid to cover two dimensional ranges with nested for loop
Nested for loops are not a good practice because for loops are using an increment to cover a range, and nested for loops are…
-
Avoid Public finalize() methods
A program should never call finalize explicitly, except to call super.finalize() inside an implementation of finalize(). In mobile code situations, the otherwise error prone…
-
Avoid confusing initialization for variables declared on the same line
Destructuring assignment are a practical sugar syntax, but due to dynamic typing, ommitting the parentheses lead to a syntactically correct, but however functionnally incorrect,…