NICOLÁS BOTTARINI
Back to the path

The path

Refactoring

479 pages of reading

Refactoring is improving the design without changing the behavior, in small steps and with the tests green the whole time. It is what makes evolutionary design possible: you don't need to get the design right upfront if you can improve it safely every day.

Topics

Stage 1 · TDD and objects
  • Refactoring Basics

    Process, Baby Steps

  • Code Smells

    Mysterious Name, Duplicated Code, Long Function, Long Parameter List, Global Data, Mutable Data, Divergent Change, Shotgun Surgery, Feature Envy, Data Clumps, Primitive Obsession, Repeated Switches, Loops, Lazy Element, Speculative Generality, Temporary Field, Message Chains, Middle Man, Insider Trading, Large Class, Data Class, Refused Bequest, Comments

  • Basic Refactorings

    Extract Function/Method, Inline Function/Method, Extract Variable, Inline Variable, Change Function Declaration, Encapsulate Variable, Rename Variable, Introduce Parameter Object, Combine Functions into Class, Combine Functions into Transform, Split Phase

Stage 2 · Design principles
  • Encapsulation Refactorings

    Encapsulate Record, Encapsulate Collection, Replace Primitive with Object, Replace Temp with Query, Extract Class, Inline Class, Hide Delegate, Remove Middle Man, Substitute Algorithm

  • Moving Features Refactorings

    Move Function, Move Field, Move Statements into Function, Move Statements to Callers, Replace Inline Code with Function Call, Slide Statements, Split Loop, Replace Loop with Pipeline, Remove Dead Code

  • Organizing Data Refactorings

    Split Variable, Rename Field, Replace Derived Variable with Query, Change Reference to Value, Change Value to Reference

  • Conditional Logic Refactorings

    Decompose Conditional, Consolidate Conditional Expression, Replace Nested Conditional with Guard Clauses, Replace Conditional with Polymorphism, Introduce Special Case, Introduce Null Object, Introduce Assertion

  • API Refactorings

    Separate Query from Modifier, Parameterize Function, Remove Flag Argument, Preserve Whole Object, Replace Parameter with Query, Replace Query with Parameter, Remove Setting Method, Replace Constructor with Factory Function, Replace Function with Command, Replace Command with Function

  • Inheritance Refactorings

    Pull Up Method, Pull Up Field, Pull Up Constructor Body, Push Down Method, Push Down Field, Replace Type Code with Subclasses, Remove Subclass, Extract Superclass, Collapse Hierarchy, Replace Subclass with Delegate, Replace Superclass with Delegate

Resources

Katas to practice

Gilded Rose

Gilded Rose

A famous kata to start your refactoring journey

Advanced beginnerMedium
View kata
Ugly Trivia

Ugly Trivia

A trivia game with ugly code ready to be refactored

ProficientMedium
View kata