|
When Should You Refactor? |
Top Previous Next |
|
I tend to refactor as I'm reading code, usually while debugging or adding features. If I need to stop and puzzle over the function of a block of code, that's a good sign that the block should be extracted into a well-named method (or even a badly-named method, since method names are easily changed later, as your understanding improves). As you improve the clarity of the code with fast, reliable, automated refactorings, often the problem becomes obvious. Buggy code is frequently unclear code (and vice versa).
|