Click here to Skip to main content
15,881,089 members
Articles / All Topics

Why Guidelines are Important in Programming

Rate me:
Please Sign up or sign in to vote.
4.67/5 (2 votes)
31 Dec 2013CPOL3 min read 9.3K   2  
A post on 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 our food. There are a certain amount of common guidelines that 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 the 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 called to clean the floor. Does this look like a civilized way of eating? Had they been taking food in a 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 need to be followed. These guidelines make sure that code is written in the right way with all the possible error handling which makes it foolproof. Code can be written without these guidelines, but will that work in all the scenarios that are positive and negative?? Many a times, developers make these 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 code without guidelines does accomplish the task in the first place but it spoils the entire product and then the 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 up for a silly thing such as the buffer was too small to handle the data. The reason being that a simple developer never thought of making this dynamic and allocated it to a static size which he thought it would never reach. This would have been a 10 minute job for a developer when he wrote it, but now, it has come up as a customer case due to which Technical support, Project management, Program Management, Architect, Developer and QA - everybody is involved. Can you imagine the cost that the company is bearing for a small mistake by a developer. This does not stop here now that the 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, the 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 is no impact due to this change.
What has happened finally is we have just introduced cost to company due to one silly mistake.
Is this acceptable ?? Shouldn't the 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 error codes API is returning and see how to handle them
  3. Add proper exception and error handling to the code
  4. Initialize the variables before you use them
  5. Release the memory after you use it, if you use managed code, then be sure Garbage collector will free your objects
  6. There should not be any buffer overflows or stack overflows in your code.
  7. Code should be unicode compliant
  8. Necessary 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 !!!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
A Technology Enthusiast since 14 Years, have been contributing in varied Domains. Interested in developing technology which goes more meaning to Human Life, Nature and the entire ecosystem.

#Developer, #Architect, #Enthusiast, #Contributor #Mentor

To all Developers out there, You touch a Billion Lives a Billion Times
Before you code Think Twice !!!

Comments and Discussions

 
-- There are no messages in this forum --