Chapter 6
Design 2 – Refactoring
Refactor: not because you know the abstraction, but because you want to find it.
– Martin Fowler
Refactoring, for me, used to mean something like, "Let me bring the bulldozer and fix all this code." I remember spending nights breaking everything apart, changing the design, and then bringing it all together again. In this process, I would easily have hundreds of tests failing while I was changing the design. This was what I called refactoring. Then, one day, I read a tweet saying something like, "Refactoring is about changing the design without changing the behavior, and it can only happen if tests are passing all the time."
After digesting the message of that tweet, I started to practice refactoring that way. I tried to use it on projects, but it led to frustration as I was too inexperienced to use it in real code. With time and more practice, I finally got to a point where I could do it. I could...