Update 'Code_Smells_Patterns.md'

main
Ashton McGlone 8 months ago
parent c0bba49b0a
commit 72e164d71b

@ -3,18 +3,22 @@
**Code Smells** are often signs that refactoring could be needed. That is not always the case, but these "smells" should be looked at further to dethermine if there is a need for refactoring. **Code Smells** are often signs that refactoring could be needed. That is not always the case, but these "smells" should be looked at further to dethermine if there is a need for refactoring.
**Duplicated Code** **Duplicated Code**
Force: Refactoring may be considered if a common structure is recongized among related methods. Force: Refactoring may be considered if a common structure is recongized among related methods.
Solution: It may be possible to generalize smaller methods to allow them to work as one. However, you must be careful to not over generalize a method and allow it to have more power than nessecary. A good metric to measure by is that a method should have between 6-9 meaningful lines of code. Solution: It may be possible to generalize smaller methods to allow them to work as one. However, you must be careful to not over generalize a method and allow it to have more power than nessecary. A good metric to measure by is that a method should have between 6-9 meaningful lines of code.
**Excessive Conditionals** **Excessive Conditionals**
Force: Refactoring may be considered if a section of code seems overloaded with conditional statements or switch cases Force: Refactoring may be considered if a section of code seems overloaded with conditional statements or switch cases
Solution: It may be possible to break these conditionals up into smaller, more conscise methods that are easier to read and have a clear purpose. Solution: It may be possible to break these conditionals up into smaller, more conscise methods that are easier to read and have a clear purpose.
**Reocurring Parameter lists** **Reocurring Parameter lists**
Force: Refactoring may be considered if a certian list of parameters keeps reappearing in many methods. Force: Refactoring may be considered if a certian list of parameters keeps reappearing in many methods.
For example: For example:
```
function(int a, int b, string c) function(int a, int b, string c)
function2(int a, int b, string c) function2(int a, int b, string c)
function3(int a, int b, string c) function3(int a, int b, string c)

Loading…
Cancel
Save