/Refactoring

From martin fowlers book

Primary LanguageJava

Refactoring Primer

Resources:

* The sacred text: Refactoring: Improving the Design of Existing Code 1st Edition
* https://refactoring.guru/

Code smells

  1. Feature Envy

    • Move method
  2. Long method

    • Extract method
    • Extract class
  3. Switch statements (🤔)

    • Replace Conditional Logic with Strategy
  4. Long class

    • Extract method
    • Extract class
  5. Long parameter list

    • Replace parameters with tuple
    • Replace constructor with builder
  6. Shotgun surgery

  7. Divergent change (Single responsibility violation)

    • Extract class
  8. Repetitive code

    • Extract class
    • Extract method
  9. Magic numbers

    • Replace Magic Number with Symbolic Constant

Other techniques