Why Deleting Old Code is the Dumbestđ Move There Is
The idea that new code is inherently better than old code is a prevalent ideology that isnât based on fact.
I wouldnât much care about it, but this ridiculous idea keeps coming back in new guises and causing damage to generations of programmers. Old code has been battle-tested, so what is this movement to throw out proven solutions with the trash as if the new is naturally superior to the old?
What is going on here?
A Trip Down Memory Lane
In the olden days people used to use âa clean slateâ as marketing copy for their software.
Quattro Pro was released to compete with Microsoft Excel but needed a push to make a real dent in Microsoftâs market share. The secret sauce was that Quattro Pro was written from scratch, and Philippe Khan (Borland founder) was all over the press boasting about the codebase being created from scratch.
This idea was idiotic then. Itâs idiotic now. Old code has been used, abused and tested in the field. Bugs have been squeezed out of the code, and the resultant functionality comes out stronger.
I havenât seen a press release referring to the codebase as being ânewâ for a long time, but I see that software developers keep pushing the same idea that the new is better than the oldâââand this attitude needs a reality check.
Code Doesnât âGo Badâ
Let me give it to you straight. The code doesnât magically get bad because itâs old. It doesnât decay, there arenât digital moths that eat the bits that make up your code. Thatâs because your code isnât a 1968 Dodge Charger sitting in a garage.
People still donât seem to get it. I had a former boss who shared their âopinionâ on our code base soon after joining the company.
âWe should delete the project and start freshâ
I mean ok, fair enough. What is the reasoning behind this insight? Someone on Twitter agreed with them that it would be a good idea. I canât agree with that reasoning, and how would we test the codebase?
The False Allure Of New Code
New Code brings the delusion that the new is better. Remember when furniture used to last for decades, and then Ikea produced wardrobes that last a few years and people thought they were âbetterâ because they were flat-packed? That, but with code.
The reality is that reading code is more difficult than writing code. Todayâs new code becomes tomorrowâs old code which is difficult to understand and maintain. Older code has already gone through code review, testing and even production meaning that the code is, by definition, good.
Next Time
Bugs can take weeks of real-world usage before they are found. Once they are found a programmer needs to reproduce the bug and fix it. It then needs to go back through the QA process and back into production.
Next time you think the new is better than the old, consider this. Donât throw away work unnecessarily.
If you want to rewrite do it with consideration. Think about optimization. Think about where optimizations can be made by iteratively improving the code.
Because when you start again you believe that you are going to do a better job than the code that is currently there. Why do you believe that? What evidence do you have?
Maybe, just maybe use data on this one? Yes?
Conclusion
You might want to refactor a class to make it easier to use. That might pay dividends and improve the codebase. Well done you! Iâm not in a company that allows that, so if you have that opportunity, I envy you.
Throwing away the whole codebase? You really need to consider this approach. I mean, are you really sure? If youâre considering throwing away battle-tested code for new code, you should make sure, your code is better than the one it replacesâââif not what is the point?