Sunday, March 08, 2020

Should developers write additional code which is not given in specifications?


The question is can developers write additional code that is not given in specifications. 

The answer to the question can be self-explained as in the image below :

A developer looking at the code would give 2 solutions to fix the above problem:
i)  Instead of using the assignment operator, the developer should have used a comparison operator as "isCrazyMurderingRobot == true"
ii) Use final keyword so that it is unalterable as "static final bool isCrazyMurderingRobert = false; "

But, I think the above two solutions are not the right ones. The problem is that the whole routine is was an unnecessary piece of code which specifies an option to kill(humans) which was not originally expected to be programmed as per the functional specification. A programmer who tried to act smart, but made a syntactical error created the whole mess.

When I was a software developer, I remember asking a product manager whether it is acceptable to write some additional functions (or methods) in the code for some extra validation which was not there in the specification. The answer that I got was an absolute "NO" and he said it will be considered as a "SIN" in the developer's job. Then I asked him why and he explained to me this.  It might be easy to add a new feature into the product by a developer but is humongous difficult to drop a feature that is there in the code. So as a developer, it might take a day to write a few hundreds of lines of code, but it takes years to remove and maintain the code.

Let's take an example of writing a connector code, a simple program that is connecting to MongoDB and as per the proposed certification matrix, it should connect to 3.5 and 3.6 versions. As a developer, you might have been proactive and added an additional check of Mongo DB version in the code. What happens with this additional check is that if the customer chooses to upgrade the MongoDB to 4.0, your code will stop to work and would require a patch to make it run. If the check was not there, it would have been a simple sanity test on your automation suite to certify the same old code with MongoDB 4.0 as well.

If you have a high urge to write that code, write it in a private branch or commented section as  proactive code that may be required in for the future.

In summary, it is a professional cardinal "SIN" to add additional code into a product mainline without a Product Manager's approval. 

No comments: