Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This question already has an answer here:

We have a project that keeps recurring. The client expects us to run a website twice a year and this is happened for the last year and a half. I took the last working copy and based our latest website on it. Now, a co-worker has suggested that next time we should start from scratch instead of fighting against legacy code.

I have already started refactoring the existing code and so have the other developers who were on the project. The code is cleaner than before and it meets client needs. The refactoring was ongoing while we developed new features.

What are some good reasons to advise against starting from scratch?

share|improve this question

marked as duplicate by Jarrod Roberson, JeffO, gnat, Bart van Ingen Schenau, Jalayn Apr 29 '13 at 14:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@MarkJ this is a bit different, I'm coming at it from the "when is a rewrite not appropriate" angle, though some of those answers are useful –  omouse Apr 29 '13 at 0:50
I'm not sure I see any difference between the questions. They are just different ways of phrasing the same choice, which is "rewrite" or "refactor". –  MarkJ Apr 29 '13 at 12:21

2 Answers 2

Rewriting it from scratch will likely take more time than refactoring and working with legacy code, unless the legacy code is truly a disaster.

Instead, I recommend spending some extra time during the beginning of each project to refactor the code more, to let you work with it more easily. This is probably a more time-effective approach, and over time, your code quality will improve

share|improve this answer

There are a few reasons to rewrite from scratch. I already mentioned them in another answer. In short, the reasons to reinvent the wheel I mentioned are:

  • Because someone doesn't know that the wheel exist already,

  • Because someone knows that the wheel exist, but doesn't like it,

  • Because someone believes she can make a commercial scale product,

  • Because it's fun.

In your case, none of those reasons seem to apply. The second reason might be valid if the code is really old and really bad (so bad it cannot be reasonably refactored), but from your answer, it seems it's not the case.

Joel Spolsky, on the other hand, mentioned why throwing away existent codebase and starting from scratch is a really, really bad idea. This article alone should convince your coworker that his suggestion may not be the best.

share|improve this answer
the coworker suggested that it would be faster and more inline with current best practices if we rewrote the code. so I guess that would be reason #2, doesn't like the current wheel. –  omouse Apr 28 '13 at 19:51
@omouse: firstly, I cloned the answer on my website, so now you can read it. Secondly, your coworker should give a more valid argument. Not liking the current codebase must be justified (see the clone). If it's thousands of lines of spaghetti code with no architecture, nobody would like to reuse it. If it just needs slight refactoring and cosmetic changes, it's better to reuse it, instead of writing from scratch and repeating the same mistakes you've already done before (one of the points by Joel). –  MainMa Apr 28 '13 at 20:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.