4 comments

[ 3.5 ms ] story [ 17.2 ms ] thread
These aren't tips for refactoring Rails. Instead, these are the 6 steps you should take -prior- to refactoring. This is an example of an editorialized title that's pretty misleading.
Actually, I think that most of these tips apply equally well to the pitfalls you might hit mid-process while refactoring.

That being said, I think the basic points are obscured by the semi-random ordering. Putting the same core recommendations into (my own, entire subjective) order of importance, I'd probably present them more like this:

1. Measure twice, cut once -- be sure you really understand a piece of code before making changes

2. Don't mix bug-fixing or feature enhancements with major refactoring work (doing minor cleanup while fixing bugs is okay)

3. Don't rip out + replace anything for which you don't have tests

4. Make sure your tests cover real-world usage, not just your internal APIs

5. Recognize when you're getting bogged down, and be willing to shelve or abandon changes

6. Set a concrete goal for your refactoring pass, and stick to it -- don't try to rewrite everything in one pass

Great tips to consider before any major refactoring task you planning.