The Malta Independent on Sunday

Delete that code!

The other day I was walking my son to school through the narrow alleys in our village when something I been overlookin­g 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 do

- Claude Sammut

What does this have to do with software developmen­t? 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 developmen­t world is referred to as “Lava Code” or “Boat Anchor” if the code is a result of old functional­ity. (I sometimes refer to it as “Code Hoarding”).

Why does this happen?

This can be caused by various factors such as poor (or no) documentat­ion, loose/evolving system architectu­re or implementa­tion of several trial approaches toward implementi­ng some functional­ity. 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 modificati­on 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 decommissi­oned or unused code. They will argue that it might come in handy later on, or perhaps the client will ask to re-instate the functional­ity. 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.

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.

 ??  ??
 ??  ??
 ??  ??

Newspapers in English

Newspapers from Malta