Sometimes, programmers find themselves rewriting an existing program. We've all done it, perhaps more often than we'd like to admit. But when you find yourself in this situation, don't call what you're doing refactoring, because it's not.
If you are in the so-called
RefactoringHell, you aren't refactoring any more.
I was just trying to explain this concept to someone the other day. I hear people use the word
ReFactoring all of the time, when they often really mean
ReWriting.
ReWriting is really
ReWorking. See
WhatIsReworking.
The act of fixing bugs or adding new functionality is not actually
ReFactoring (no matter what you might hear).
ReFactoring simply makes it easier to do so.
TestDrivenDevelopment provides another way to look at this.
- TestDrivenDevelopment
- write a UnitTest, get the test to pass, then ReFactor (EliminateDuplication, etc.).
So,
ReFactoring is clearly not the act of getting the tests pass. It's about how to restructure the code in such a way that preserves the behavior that causes the tests to pass.
--
JasonNocks
See
WhatIsRefactoring
CategoryRefactoring CategoryMisconception