31 Days of Refactoring

Refactoring is an integral part of continually improving your code while it moves forward through time. Without refactoring you accrue technical debt, forget what portions of code do and create code that is resistant to any form of testing. It is an easy concept to get started with and opens the door to much better practices such as unit testing, shared code ownership and more reliable, bug-free code in general.

Because of the importance of refactoring, throughout the month of August I will be describing one refactoring a day for the 31 days of August. Before I begin, let me prefix this series with the fact that I am not claiming ownership of the refactorings I will describe, although I will try to bring some additional description and perhaps some discussion around each. I have chosen not to list the full set of refactorings on this first post until I actually post the refactoring. So as the month progresses I will update this post with links to each of the refactorings.

First on the list is credit where it is due. The majority of these refactorings can be found Refactoring.com, some are from Code Complete 2nd Edition and others are refactorings that I find myself doing often and from various other places on the interwebs. I don’t think its important to note on each refactoring where it came from, as you can find refactorings of similar names found on various blogs and articles online.

On that note, I will be publishing the first post starting tomorrow that begins the 31 day marathon of various refactorings. I hope you all enjoy and learn something from the refactorings!


  1. Refactoring Day 1 : Encapsulate Collection
  2. Refactoring Day 2 : Move Method
  3. Refactoring Day 3 : Pull Up Method
  4. Refactoring Day 4 : Push Down Method
  5. Refactoring Day 5 : Pull Up Field
  6. Refactoring Day 6 : Push Down Field
  7. Refactoring Day 7 : Rename (method, class, parameter)
  8. Refactoring Day 8 : Replace Inheritance with Delegation
  9. Refactoring Day 9 : Extract Interface
  10. Refactoring Day 10 : Extract Method
  11. Refactoring Day 11 : Switch to Strategy
  12. Refactoring Day 12 : Break Dependencies
  13. Refactoring Day 13 : Extract Method Object
  14. Refactoring Day 14 : Break Responsibilities
  15. Refactoring Day 15 : Remove Duplication
  16. Refactoring Day 16 : Encapsulate Conditional
  17. Refactoring Day 17 : Extract Superclass
  18. Refactoring Day 18 : Replace exception with conditional
  19. Refactoring Day 19 : Extract Factory Class
  20. Refactoring Day 20 : Extract Subclass
  21. Refactoring Day 21 : Collapse Hierarchy
  22. Refactoring Day 22 : Break Method
  23. Refactoring Day 23 : Introduce Parameter Object
  24. Refactoring Day 24 : Remove Arrowhead Antipattern
  25. Refactoring Day 25 : Introduce Design By Contract Checks
  26. Refactoring Day 26 : Remove Double Negative
  27. Refactoring Day 27 : Remove God Classes
  28. Refactoring Day 28 : Rename boolean methods
  29. Refactoring Day 29 : Remove Middle Man
  30. Refactoring Day 30 : Return ASAP
  31. Refactoring Day 31 : Replace Conditional with Polymorphism
‘Vice’ Testing