Fix(guide): Add more examples of code-smells

pull/25491/head
Paul Isaris 2018-10-21 21:27:20 +03:00 committed by Heather Kusmierz
parent 5e8d071a18
commit 76388feedb
1 changed files with 3 additions and 0 deletions

View File

@ -10,6 +10,9 @@ It is important to understand that smelly code works, but is not of good quality
#### Examples #### Examples
1. Duplicated code - Blocks of code that have been replicated across the code base. This may indicate that you need to generalize the code into a function and call it in two places, or it may be that the way the code works in one place is completely unrelated to the way it works in another place, despite having been copied. 1. Duplicated code - Blocks of code that have been replicated across the code base. This may indicate that you need to generalize the code into a function and call it in two places, or it may be that the way the code works in one place is completely unrelated to the way it works in another place, despite having been copied.
2. Large classes - Classes having too many lines of code. This may indicate that the class is trying to do too many things, and needs to be broken up into smaller classes. 2. Large classes - Classes having too many lines of code. This may indicate that the class is trying to do too many things, and needs to be broken up into smaller classes.
3. [Magic numbers](https://en.wikipedia.org/wiki/Magic_number_(programming)) - Variables (or `if` statements) scattered in the code that hold numeric values with no apparent meaning.
4. Many-parameter methods - Methods that take more that 2 or 3 parameters usually indicate that the method does more than one thing and should be broken down to multiple methods.
5. Unclear method or variable naming - A programmer should be able to understand what a method does without looking at the method's body. If the name or the parameter naming is vague, it is an indicator that the method should be refactored to reveal its purpose in the code.
#### More Information: #### More Information:
* _Refactoring: Improving the Design of Existing Code - Kent Beck, Martin Fowler_ * _Refactoring: Improving the Design of Existing Code - Kent Beck, Martin Fowler_