The first step in refactoring is to build a solid set of unit tests around the code you want to refactor.
In the timeless book "Refactoring" by Martin Fowler says this under the heading The First Step in Refactoring :
"Whenever I do Refactoring, the first step is always the same. I need to build a solid set of tests for that section of code. The tests are essential because even though I follow Refactorings structured to avoid most of the opportunities for introducing bugs, I'm still human and still make mistakes. This I need solid tests."
- Martin Fowler, Refactoring : Improving the Design of existing Code (p7)
Wow, this is an incredible little paragraph tucked away in the first few pages of the book.
The posts on this site are written and maintained by Jim Lynch. About Jim...