Update 'Code_Smells_Patterns.md'

main
Ashton McGlone 8 months ago
parent 3339822867
commit 91d2018e59

@ -6,7 +6,7 @@
* 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-8 meaningful lines of code.
**Excessive Conditionals** **Excessive Conditionals**
@ -17,6 +17,7 @@
**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)
@ -24,4 +25,28 @@ function2(int a, int b, string c)
function3(int a, int b, string c) function3(int a, int b, string c)
``` ```
* Solution: It may be possible to group these parameters into an object and instead pass the object around to different functions rather than passing each parameter. * Solution: It may be possible to group these parameters into an object and instead pass the object around to different functions rather than passing each parameter.
**Big Objects**
* Force: Refactoring may be considered if an object has many methods and variables.
* Solution: It may be possible to break this object up into a few smaller objects. This can be done for readability, simplicity, and overall funtionality.
**Big Methods**
* Force: Refactoring may be possible when a method is getting too large. (over 7 lines of active code)
* Solution: It may be possible to break this method up into smaller methods. Methods shoudl have a clear purpose and should not take on work it does not have to.
**Magic Numbers**
* Force: Refactoring may be possible when it is noticed that there are many hard-coded values and and seemingly random literals scattered throughout the code.
* Solution: It may be possible to give these vauge "magic numbers" variable names to make the code easier to read, understand, test, and maintain.
**Feature Envy**
* Force: Refactoring may be possible when it is noticed that a certian object seems to have significantly more features than other objects it is interacting with.
* Solution: It may be possible to had work off to some of these smaller objects. If the original object is reaching out to grab things that are much easier access and handled by the secondary object, than a consideration should be made to give that work to the secondary object.

Loading…
Cancel
Save