Develop against the Rewrite Virus

So what is this rewrite virus? It’s the virus that infects you every time you have to decide whether to take over an existing code base or propose to do a rewrite. Now a lot has been written already about the negative effects of “starting from scratch”. One of the most influential articles on the subject was written by Joel Spolsky. You can read it here.

Even years after that article (and many others), I still see developers proposing to rewrite parts of or even complete software systems. We have now a clear idea of why this, as Joel puts it, is “something you should never do”. But do we know why this happens? Why is this tendency amongst developers so persistent? Understanding this might help us making it easier to create code that others might not want to rewrite so quickly.

It’s all about control

After asking many developers why they decided to rewrite rather than taking over existing code, all the answers boiled down to one simple thing. Taking over made them feel as they were not in control of the code. Rewriting made them feel they are in control.

Of course, this is not that simple in real life, as you start losing control of your own code sooner or later if you don’t practice merciless refactoring and other techniques. This loss of control is called software entropy, a term coined in the book “The Pragmatic Programmer“.

So what can we do to avoid the rewrite virus? Write code that other developers would not immediately want to rewrite. Write clean code and aim for a clean architecture that communicates the intent of the system. Write tests that run fast and are easy to set up, so new developers can control the system as soon as possible. Create a development environment that others can easily feel in control of.



No comments yet.

Leave a Reply