Every programmer has her own style of coding like some use ‘inum’ for declaring an integer variable while some use ‘num_i’ for declaring the same. Like wise some programmers are lazy enough to add comments. These small drops when added together can create an ocean of confusion. https://intelvision.pro/services/dedicated-software-development-team/
What is a coding standard?
Coding standard is establishing one single coding style (convention) for whole project or organization and making programmers strictly follow it. This is also known as programming style or coding conventions. Usually coding styles differ from language to language, but it is better to establish one standard for one language. Later in this article we shall discuss ways of coding standards
Why one should use it?
1. Easy to understand others code – Due to differing programming styles of programmer; it is sometime hard to easily read coding done by someone else. If all programmers starts using same convention this problem can be eliminated up to some extend.
2. Easy to use and debug program – if coding standard is followed, it will be easy to debug the program due to two factors, firstly some bugs can be totally eliminated which are caused due to poor naming and indenting of code, and secondly, it will be easy to debug programs of fellow programmer. It is important to consider the second reason sometimes, when debugging, if you are stuck at a point, just ask any of your friend, she will get the error in no time. This is due to your ignoring of a portion and considering it is right, but a second person will try to understand your logic and will search more thoroughly than you.
3. Increase in productivity – as I mentioned earlier that Nagaraja is facing complains of new employee on his RAD team. This will certainly not come to you if your development team is following a coding standard. This way productivity will ascend.
4. Decreasing program complexity – program can become complex not only due to logic of program but also due to gibberish coding done by the developer. If better indenting and naming convention is followed, this problem will not come.
5. Staffing Flexibility – New people can be easily added to the project because it will be no problem for new member to start producing. The only need is to understand the coding standards.
6. Re-use of code – If the code is not complex and based on standards, one can easily re-use it in some other project. This re-use can be direct or with some modification. In any of these two cases coding standards will really pay-off.
Few standards used worldwide
Different computer languages need different coding style, but there are some basic points where we can discuss coding styles on.
1. Variable Declaration and naming conventions
In declaration of variable some conventions can be followed. Some rules must be defined for declaration variables –
a.Name of variable must not be randomly chosen. The name must clearly state the purpose of that variable.
b.Datatype of the variable must be included in the variable name. As this is suggested in VB 6.0 manual to use “txt_textboxname” as name of a textbox and “lbl_labelname” as name of a label object. This should be used and also a fixed convention for this should be clearly stated.
c.All variable should be declared in small letter and all constants in capital letter. This is very important for case sensitive languages.
d.No re use of any variable name. It is easy to use same variable name in more than one block of coding. This practice should be highly undesirable and should be avoided at first place.
e.All global variables should use a naming pattern this will help developer to avoid accidental modification of global data.
2. Commenting standards
First of all, all developers should be encouraged to do maximum commenting. This is never considered as wastage of time, it increases readability of coding. Some comments should be enforced as mandatory, one of such comment can be the comment at the top of all programming page like –
Name of Module
Last Modified By –
Modification History –
This comment will always be very useful for the software configuration team to get the latest version of codes.
3. Indenting and formatting
This is also called beautifying the codes. Indenting is cascading your codes in such a manner that all nested blocks of your code can be easily separated with each other. This is highly recommended. Normally one can use one tab for each inner nesting and so on. This is the best indenting followed by programmers.
4. Program return value
Usually when a main function of program is terminated, it returns an end status value in integer. There is no set convention for this value, but we can set this as a convention. For all successful termination program should return a value of ‘0’ and for any error it should return the proper error code in integer. This error code should be a non negative integer value greater than or equal to 1.