Clean Code
Reinforces the importance of code quality and presents many code smells and refactoring techniques.
Refactoring
Basically rewrite the code to eliminate Code Smells. Ideal to write the tests of the code to be refactored, covering 100%, before refactoring.
Code Smells
A smell is a symptom that occurs in the code and can be an indicator of problems.
Strange variable names, methods and classes.
Declared names must be clear in relation to its purpose.
Excessive comments.
Good code is self explanatory.
Using good names helps to reduce comments.
Dead code.
Ex.: Commented code.
Empty lines. (Controversy)
Duplicated code.
Maybe it can be extracted.
Long params list.
May indicate an anemic object. (It doesn't have self caracteristics, only receives from outside)
Variables declared away from its use.
Too many nested conditions.
Nested ternary conditions also bad.
Lack exception treatment.
Avoid returning arbitrary values to work as errors. (Like -1, 0, etc)
Last updated