Coding standards and guidelines

In this tutorial, we will learn about the various coding standards and guidelines and regarding their necessity in software engineering. By Monika Sharma Last updated : April 06, 2023

What are coding standards?

Coding standards are the set of guidelines or norms that are globally set or are set by various software development organizations (and they hold only to that particular organization) and these guidelines should be followed by all the developers to produce a good quality software.

Benefits of using the coding standards

There are various benefits of using the coding standards while coding the software like,

  • Code understanding becomes easier
  • Entire code of the whole software has same format and style of coding
  • Encourages good programming skills

Common coding standards and guidelines

Most of the top software developing companies set their coding standard by their own and these standards are followed by the developers of that particular organizations only. However, there are some common representative coding standards and guidelines that are more overly applicable to all and are mostly followed by every developer or organization.

The following are the common coding standards and guidelines are:

  1. Rules for global variables declaration
  2. Naming conventions
  3. Contents of headers
  4. Error return conventions
  5. Use coding style that is easy to understand and is globally accepted
  6. The length of functions or methods should be small
  7. Do not unnecessarily use statements that break the control flow of statements
  8. Choose identifier names uniquely within the module

Let's discuss each guideline in details.

1) Rules for global variables declaration

There are rules which define what type of variables can be declared as global and what cannot. This helps to maintain the confidentiality of the data and is also helpful in cases where the access rights are to be provided only to the selected group of users.

2) Naming conventions

Naming conventions are set for declaring any sort of entity or variable within the software. This provides a regularity in the structure of the names defined. For example, ‘every button should have its name in all capitals’ can be a naming convention.

3) Contents of headers

The data that must be there in the header of each module has a pre-defined format. This usually includes the name of the module, data of creation, date of approval, developer’s or author’s name, synopsis, description of the module, description of the variables and functions defined in the module, etc.

4) Error return conventions

There are certain conditions in which the input data is bounded within some range. If in such cases, the data entered by the user exceeds the particular range, then an error message should be displayed. The range and criteria for which the error should pop up is defined in the error return conventions.

5) Use coding style that is easy to understand and is globally accepted

It is recommended that the coding style that is being followed must be easy to understand and should be similar to that which is globally accepted or else it would be difficult for the user to understand it and also it would take time for the developers to develop a habit of following a completely new coding format.

6) The length of functions or methods should be small

It is a good practice to keep the body of the functions small, nearly about 10-12 code lines. This makes the code readable and easily modifiable.

7) Do not unnecessarily use statements that break the control flow of statements

It is advised not to use jump, goto and function calls unnecessarily as it takes extra time for the processor to break the going flow, search for the mentioned statement, load those statements, execute them and then return to the previous calling function. Therefore, try to avoid such situations as much as possible.

8) Choose identifier names uniquely within the module

Every identifier at least within the module must have a unique name to avoid ambiguity.





Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.