views:

492

answers:

4

With legacy code, how do you know when it's best to rewrite over refactoring?

A: 

One factor to look at: would it take less time to rewrite than to disect and refactor the code?

Joseph Daigle
A: 

I think the question is, how do you tell which would take less time, a complete rewrite or a refactor of existing code.

The answer probably has something to do with a different question: can you, upon glancing down the code, immediately see what chunks can be separated out into usable modules, and upon testing a positive answer by trying a few small cases, did the program break?

If you could not immediately see a way, or the program broke when you tried a few small cases, it was probably badly enough written that it needs a rewrite.

Zed