Default Banner

Delete that code!

Delete that code!

The other day I was walking my son to school through the narrow alleys in our village when something I been overlooking for the past few years made me think. How many of those utility lines hanging up above my head are actually in use? I counted over a dozen lines for a little alley with a handful of residents. Clearly, most of them were old and possibly no longer in use but the disconnected lines had not been removed. Presumably, no one bothered to remove the old lines when installing new ones.

What does this have to do with software development? Sometimes the situation is very similar. Over the years, I have seen many projects, some of which had changed hands various times. In most of these, I tended to come across chunks of code that were not being used and some of which may even have been commented out. In projects that have been around for several years, I also tend to find whole sections that are not being used, yet the code is kept there.

Such “phenomenon” in the software development world is referred to as “Lava Code” or “Boat Anchor” if the code is a result of old functionality. (I sometimes refer to it as “Code Hoarding”).

Why does this happen?

This can be caused by various factors such as poor (or no) documentation, loose/evolving system architecture or implementation of several trial approaches toward implementing some functionality. Some of these reasons are inevitable so be ready to delete the code when you hit that stage!

But the system works!

You could think that leaving old code, no harm would be done to the system, or perhaps even think that the system would still work with the extra code. You are not entirely wrong, the system will still work with the extra unused code but there are several problems with that…

  • Extra code will make the project look complex or messy.
  • When you eventually hand over the system to someone else (because no one wants to work on the same system forever) it will make it harder for them to maintain it.
  • In some cases, it could be you that have revisited the code years later for some modification and have to go over the routine to refresh your memory on how it works.

Remember that the best code is no code, it will never fail!

What if I need it later?

Any chunk of code is a developer’s pride and perhaps that is why most developers think a hundred times before deleting their decommissioned or unused code. They will argue that it might come in handy later on, or perhaps the client will ask to re-instate the functionality. From my experience, I can say that you will never need that code again. However, if you do need to refer to that code you can always restore it from source control. If for some reason that is not an option, resort to other means (such as old fashioned text files), but please, delete that code! Less is more.

Claude Sammut is a software developer at Deloitte Digital Malta. For more information, please visit