Handling The Junk Code

While writing applications most of us have the bad habit to abandon few pieces of code here and there in the process of optimization and performance tuning. Few lines of codes get completely replace by better ones and few need little tweaks here and there though, there is a good amount of code which is replaced by better ones not because they are useless but not suitable for that particular situation. Since we know this truth, we find it very hard to delete that code, instead we keep a copy of it somewhere in the same program in an area where few other codes are dumped. This place looks like a junk yard which has high potential but definitely not very organized one.

If somebody likes the code very much and does not want to throw it into the junk corner, they hide it under the comment section and put add a TODO or UTILS line above it, surely a very bad practice for production.

code

So, What to do with this Lovely Junk?

So what to do with this box full of good but unused code and where do we put it so it can be utilized in the later course of time? Definitely this box has to be kept far far away from the production code. Why? Since these codes have been replaced by others there is a big chance that the new code(generally a method, function or a Class) happens to have the same name and often same signature too. Its pretty clear that having multiple codes with same signature can have catastrophic effect in the later run when a new developer join the team.

A good solution would be to take the code away and put it in a repository where it feels safe and can be revisited and shared with other members. If the project is Open Source in nature, putting the junk code in an online code repository and in the organization’s own private code repository. One thing that has to be taken care of is that, it has to be put in a repository separate from the actual project. This will surely save time as developer does not have to re write the code again from scratch.

Happy Coding 🙂

Advertisements

Why I Hate Software Developers

Being a Software Developer I know how slow and counter productive developers get with time. Its not that we don’t get time to meet the deadline(although exceptions are always there), it is just our thought of thinking ourselves as highly efficient and over qualified.
We always hate testers since they put us back to work and make us clean up our own mess. But it is just their job to put developers on job and guide the software development on a right path. Sometimes I feel, it is the testers who put the developers on the right track.
But wait, sometimes even testers get lazy too. The code in alpha and pre releases gets their nod to be released but when the code is in production suddenly some tester would raise a finger on a very trivial issue that should have been found during the pre release stage.
This time I as a developer think how stupid and lazy the tester was for not to find this trivial bug, but eventually this thought comes back to me as a boomerang asking why on earth did the developer not notice such a blunder. At this time I feel serious identity crisis for myself.

 

The Dream:

There is a saying “Good developers write their own code, but the best developers utilize already written code“. Now having said that I must admit, almost every coder has a dream to right the code from scratch and never wants to manage and clean up someone’s mess.
Apparently very few lucky ones get that chance, rest of us have to cope up with the situation. The situation gets even worse when the code has already been changed by more than four or five different people. The person currently working on the code has to somehow understand and manage the coding styles and thinking of coders before him.
The best thing is that the current developer will surely manage to get the code working. This situation remains almost every time the developers change their jobs. There is a worst thing about this: no manager will let you get away with this silly argument, even though they themselves understand the situation very well.

 

What exactly did you do? This is just a minor change; This is a general question asked by several managers. The problem gets worse if the change is related to UI. The developer has to take care of several others elements nearby to move one simple button from left to right. In the outcome(from a user’s or manager’s perspective) it is just a re-positioning of a button, but it is the developer who knows the pain behind it.
Yes it is true that a good coding practice can reduce the amount of work, but don’t forget that the code has already been modified by several other developers who are not in the project any more, so the current person in the developer’s cap has to bear it.

 

Despite of all these things and situations we somehow learn to “MANAGE” and not to break any existing functionalities of the software. With time we get mature and acquire better skill sets to provide better solutions to problems and sometimes you get appreciations too for that. This little piece of appreciation helps developers a lot to again start thinking themselves as a better creatures, hence the cycle of fall and rise continues. We don’t get out of it and that’s why I hate software developers or more specifically myself.