Thursday, January 29, 2009

Code Rewrite : why it is bad ?

Well what is code rewrite ? It is a strategic decision to scrap all code you have ever written for a software product and rewrite it from scratch, thinking that will give you better quality code & will be easy to maintain.

Stay away from rewriting a whole code base thinking the old one is terrible.

I have personally seen that being a bad decision many times. Joel on software has very interesting real stories to tell here.

Why it is bad ? Here are some reasons I have felt -

1) Lots of developer effort going down the drain.
The old code base say it was 3 to 5 years old has had lots of development effort already go in. Notwithstanding while writing the new code base do you have better developers and designers than what you had previously ? Otherwise you could end up with a code that may no seem readable and hence maintainable but not really superior.

2) Quality Assurance person's time. Your QAs would have already done lots of testing. Now, to get back a fresh piece of code to that quality is not a simple task. Have you documented all test cases / use cases ?

Fresh Code to reach the quality of Old code with all Use Cases handled will take time.

3) What about the hundreds of invaluable testing already done by customers ! Think about it. There are lots of customer environment specific issues. How did you fix it or what was the fix ? Can you reproduce that in your labs and support it ? BTW those 100s of small enhancements took that extra week each to support.

4) If you are going to maintain the old one too, then its going to be a bigger nightmare because you are going to distribute your work on 2 code bases. That is going to slow you down.

5) Remember Customers do not buy your software after reading your code. But they want the software to work, otherwise they are going to complain. Complain real loud.

6) When you rewrite code, cultutrally people expect a better featured product from what was previously present. Most people comment on the GUI as that's all they really see. Now these expectations futhur increase the time taken to go to market.

Ofcourse code rewrite for a small piece of software is absolutely fine. The above post is more from a perspective where there is a major rewrite from scratch of a full software product maybe which had over 500 man years of development effort.

So what should I do when I have feel there is a need to rewrite code ? Well Follow the 80 - 20 rule. Most probably 80% of the problems are caused by 20% of the code. Even here first identify the problematic code and be very straight to the point on how you fix. Do only Design fixing where it is absolutely needed. Fix only the flow problems or the design problems - meaning creating interfaces, and deciding on the right approach etc and donot take up anything that does not need to be touched. Do not evaluate new frameworks especially for DB persistence etc. Also look at the revision history. If the code has not been touched for years, then you may not have to even change it as it is actually working.

To summarize I guess code rewrite is bad especially for large projects. The main reason being the difficulty to get the new code to reach the quality and richness as the old.

No comments: