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 had 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 in one small alley with a handful of residents. Clearly, most of the lines were old and possibly no longer in use but, if there were old or disconnected lines, then they had not been removed. Presumably, no one bothered to do the clean up when installing new ones.

What does this have to do with software development? Sometimes the situation is very similar. Over the years, I have expreienced many coding many projects, some of which have changed hands multiple times. With most of these, I wouldo come across chunks of code that were not being used and some which may even have been commented out. Still today, in projects that have been around for several years, I tend to find whole sections that are not being used, yet the code is still kept there.

Such 'phenomenon' in the software development world is referred to as “Lava Code” or “Boat Anchor”, whereby 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 functionality. Some of these reasons are probably inevitable but programers must be ready to delete the unsused code after finalising goals!

But the system works!

You might think that by leaving old code, no harm is being done to the system. Or, perhaps you might even think that the system can still function regardless of the extra code... and you would not be entirely wrong - the system will still work with extra unused code but:

  • 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 someone else to maintain it.
  • In some cases, it could be you that revisit the code years later for a modification and have to go through all the extra routines to refresh your memory on how it works.

Remember: 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 procrastinate before deleting their decommissioned or unused code. They will argue that it might be useful later on, or that perhaps the client will ask to re-instate the functionality. However, it is generally safe to say that you will never need that code again. If you do need to refer to old code you can always restore it from source control. If for some reason that is not an option, there a reother means (such as old fashioned text files), but please, delete that code, as less is more.

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