The Pragmatic Programmer wrote:
When Should You Refactor?
When you come across a stumbling block because the code doesn't quite fit anymore, or you notice two things that should really be merged, or anything else at all strikes you as being "wrong," don't hesitate to change it. There's no time like the present. Any number of things may cause code to qualify for refactoring:
Duplication You've discovered a violation of the DRY principle (Don't Repeat Yourself) Nonorthogonal design. You've discovered some code or design that could be made more orthogonal Outdated knowledge. Things change, requirements drift, and your knowledge of the problem increases. Code needs to keep up.[/b] Performance. You need to move functionality from one area of the system to another to improve performance.
Paul Clapham wrote:I'm sure you've had the experience of looking at something you wrote a few years ago and asking yourself what you were thinking back then. I know I've had that experience.