Sunday, December 29, 2013

Why Guidelines are important in Programming

Completing every task is important but how you complete it, is equally important !!!
Guidelines are one of the building blocks for any foundation. We do follow Guidelines almost everywhere in our life like Walking on the Street, Driving a Car, or having a Food. There is a certain amount of common guidelines are followed almost everywhere.

People can say they had lunch but was this the right way to have lunch ??
How would it be if people in cafeteria don't take the food in the plate and just barge in, which creates a big chaos and finally they end up spoiling the entire place.Then somebody from housekeeping is being called to clean the floor.Does this looks civilized way of eating had they been taking food in plate they would have avoided the chaos and also cleaning required from housekeeping.

Following Coding Guidelines should be the Developers first religion !!!
While doing programming there are certain Coding Guidelines which needs to be followed.This guidelines make sure that code is written in right way with all the possible error handling which makes it foolproof.Code can be written without this guidelines but will that work in all the scenarios that is positive and negative ??Many a times developer do this mistakes of not following the guidelines and just writing the code they feel is correct, this works fine in positive test cases but starts failing badly in negative scenarios.
Writing a code without guidelines does accomplishes the task in the first place but it spoils the entire product and then company has to invest time and money in cleaning it up.

My personal Experience.........
I have seen lot of scenarios in which serious issues did came for a silly thing that buffer was too small to handle the data. The reason being simple developer never thought of making this dynamic and allocated it to a static size which he thought it would never reach.This would be have been 10 mins job for developer when he written it, but now it has come as customer case due to which,Project management,Programme Management, Architect,Developer,QA everybody is involved.Can you imagine the cost that company is bearing for a small mistake by a developer.This does not stops here now developer needs to reproduce the scenario which again takes time, then there is regular follow up with team at customer site and all the stake holders.Finally after identifying the issue developer fixes it and makes the release.But now QA has to re-validate not only that Defect but certify the product again that there are no impacts due to this change.
What has happened finally we have just introduced cost to company due to one silly mistake.
Is this acceptable ?? Shouldn't developer be following a basic guideline before he writes the code ??

How can we make it better ??
There are some basic Guidelines that any developer in any programming language should follow
  1. Think of all the scenarios before you write the code, consider both positive and negative
  2. While writing the code,read the API documentation carefully, check what all error codes API is returning   and see how to handle them
  3. Add proper exception and Error handling to the code
  4. Initialize the variable before you use them
  5. Release the memory after you use it, if you use manage code than be sure Garbage collector will free your objects
  6. They should not be any buffer overflows or stack overflows in your code.
  7. Code should be unicode compliant
  8. Neccessary arrangement for localization should already be done
  9. Check the data which is being processed is of static or dynamic size and take decision accordingly.
  10. Divide the code in smaller functions, which makes it more readable, reusable & maintainable.

Thinking Positive is Good but only positive is not Good !!! 

1 comment:

  1. nice written. it's been a year now since i am working in same industry as you and feeling the same when i started my career my senior keep telling me name it like this.. give documentation header and all.. follow these conventions.. etc. at that time i was pretty unaware about all these things but yeah gradually i got to know how these things are important for a project and it's cost. : Deepak Soni (JSE)