You have to write code to delete code
I recently had again masons at my place. I took off the wainscot in our living room and the wall behind it was in a horrible condition. So I had a chance to see a mason making a new, smooth, coat on top of the old wall.
The secret for a straight coat? Place a bunch of straight aluminum bars in key spots of the wall as reference points. Make sure they are tall as the wall itself and perpendicular to both the floor and the ceiling. Those are your “rails”. Then spread the plaster with a trowel or a similar tool. The coat will never be straight of course, because you can’t be precise with the trowel. So put some extra plaster. Then take another straight aluminum bar, start from the bottom and let it slide on the rails to remove the extra plaster. You’ll end up with a smooth and straight surface. Let it dry then paint it.
I can’t help but think that developing software products follows a pretty similar pattern, in particular when you are building the first version of a new product:
- you need some reference points, features or goals
- then you start “spreading” lines of codes at the problems you face
- during the process you will end up with unneeded or even duplicate code
- when it’s time to “make the product straight”, for example by improving the performance or enhancing maintainability you’ll refactor and remove the extra code
I adopt a pretty similar pattern even when I write blog posts and presentations. I write extra content and then I keep the best, or the one that fits the purpose.
If you adopt a different approach please write a blog post about it. I am eager to know different perspectives about this.