Skip to content

Instantly share code, notes, and snippets.

@obliviusm
Last active August 29, 2015 14:24
Show Gist options
  • Save obliviusm/a34446b6987b7c051f98 to your computer and use it in GitHub Desktop.
Save obliviusm/a34446b6987b7c051f98 to your computer and use it in GitHub Desktop.
Object-Oriented Design and Refactoring Patterns in Ruby

Object-Oriented Design and Refactoring Patterns in Ruby

Code Smells

Each item in the following list matches a code smell and contains a list of possible refactoring patterns to solve it.

  • Duplicate code

    • Extract Method
    • Pull Up Method
    • Form Template Method
  • Long method

    • Extract Method
    • Replace Temp with Query / Replace Temp with Chain
    • Introduce Parameter Object / Preserve Whole Object
    • Replace Method with Method Object
  • Feature envy - «функциональная зависть», функціональна залежність

    • Extract Method + Move Method
  • Data clumps

    • Extract Class
    • Introduce Parameter Object / Preserve Whole Object
  • Comments

    • Rename Method
    • Extract Method
    • Introduce Assertion
  • Divergent change

    • Extract Class
    • Inline Class
    • Move Method + Move Field
  • Primitive Obsession

    • Replace Type Code with Polymorphism / Module Extension / State|Strategy
    • Replace Array with Object
    • Introduce Parameter Object
  • Conditionals (if/else, case/when)

    • Introduce Null Object
    • Replace Type Code with Polymorphism
    • Extract Method + Move Method

Refactoring Patterns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment