An oldie but goodie...<p>The only exceptions I can think of are:<p>1) The state of the art has fundamentally changed. In this case you are not actually <i>re-writing the same thing</i>. Rather, you are writing something new that obsoletes the old thing. For example, one might replace a string matching based spam filter with a Bayesian spam filter.<p>2) The architecture is fundamentally different. For example, you might have to rewrite to port a piece of high performance computing code from MPI to GPGPU, or to make something single threaded aggressively multi-threaded. It might require a whole new approach to the problem.<p>3) I do believe that there exist code bases that are <i>so fracking gawd-awful</i> that there is nothing to be done with them but take them out behind the barn and shoot them in the head. But these are in the minority, and usually they never worked well or established any kind of "market leading position" to begin with. (If they did, it must not have been a crowded market.)
<i>There's a subtle reason that programmers always want to throw away the code and start over. The reason is that they think the old code is a mess.</i><p>This one hits the nail on the head, also, maybe it's better since you did it yourself, rather than somebody else?<p>Rather than reading someone else's code, it's better to write your own..<p>then the next guy comes along and does the same thing to your old code..