Coding Standards and Guidelines
Last Updated :
23 May, 2024
Different modules specified in the design document are coded in the Coding phase according to the module specification. The main goal of the coding phase is to code from the design document prepared after the design phase through a high-level language and then to unit test this code.
What is Coding Standards and Guidelines?
Good software development organizations want their programmers to maintain to some well-defined and standard style of coding called coding standards. They usually make their own coding standards and guidelines depending on what suits their organization best and based on the types of software they develop. It is very important for the programmers to maintain the coding standards otherwise the code will be rejected during code review.
Purpose of Having Coding Standards
The following are the purpose of having Coding Standards:
- A coding standard gives a uniform appearance to the codes written by different engineers.
- It improves readability, and maintainability of the code and it reduces complexity also.
- It helps in code reuse and helps to detect errors easily.
- It promotes sound programming practices and increases the efficiency of the programmers.
Coding Standards in Software Engineering
Some of the coding standards are given below:
- Limited use of globals: These rules tell about which types of data that can be declared global and the data that can't be.
- Standard headers for different modules: For better understanding and maintenance of the code, the header of different modules should follow some standard format and information. The header format must contain below things that is being used in various companies:
- Name of the module
- Date of module creation
- Author of the module
- Modification history
- Synopsis of the module about what the module does
- Different functions supported in the module along with their input output parameters
- Global variables accessed or modified by the module
- Naming conventions for local variables, global variables, constants and functions: Some of the naming conventions are given below:
- Meaningful and understandable variables name helps anyone to understand the reason of using it.
- Local variables should be named using camel case lettering starting with small letter (e.g. localData) whereas Global variables names should start with a capital letter (e.g. GlobalData). Constant names should be formed using capital letters only (e.g. CONSDATA).
- It is better to avoid the use of digits in variable names.
- The names of the function should be written in camel case starting with small letters.
- The name of the function must describe the reason of using the function clearly and briefly.
- Indentation: Proper indentation is very important to increase the readability of the code. For making the code readable, programmers should use White spaces properly. Some of the spacing conventions are given below:
- There must be a space after giving a comma between two function arguments.
- Each nested block should be properly indented and spaced.
- Proper Indentation should be there at the beginning and at the end of each block in the program.
- All braces should start from a new line and the code following the end of braces also start from a new line.
- Error return values and exception handling conventions: All functions that encountering an error condition should either return a 0 or 1 for simplifying the debugging.
Coding Guidelines in Software Engineering
Coding guidelines give some general suggestions regarding the coding style that to be followed for the betterment of understandability and readability of the code.
Some of the coding guidelines are given below :
- Avoid using a coding style that is too difficult to understand: Code should be easily understandable. The complex code makes maintenance and debugging difficult and expensive.
- Avoid using an identifier for multiple purposes: Each variable should be given a descriptive and meaningful name indicating the reason behind using it. This is not possible if an identifier is used for multiple purposes and thus it can lead to confusion to the reader. Moreover, it leads to more difficulty during future enhancements.
- Code should be well documented: The code should be properly commented for understanding easily. Comments regarding the statements increase the understandability of the code.
- Length of functions should not be very large: Lengthy functions are very difficult to understand. That's why functions should be small enough to carry out small work and lengthy functions should be broken into small ones for completing small tasks.
- Try not to use GOTO statement: GOTO statement makes the program unstructured, thus it reduces the understandability of the program and also debugging becomes difficult.
Advantages of Coding Guidelines
- Coding guidelines increase the efficiency of the software and reduces the development time.
- Coding guidelines help in detecting errors in the early phases, so it helps to reduce the extra cost incurred by the software project.
- If coding guidelines are maintained properly, then the software code increases readability and understandability thus it reduces the complexity of the code.
- It reduces the hidden cost for developing the software.
Conclusion
Coding standards and guidelines ensure consistent, readable, and maintainable code, promoting efficient development and error detection. They standardize naming, indentation, and documentation practices, reducing complexity and facilitating code reuse. Adhering to these practices enhances overall software quality and development efficiency.
Similar Reads
Design Goals and Principles of Object Oriented Programming The fundamental goal of dealing with the complexity of building modern software naturally gives rise to several sub-goals. These sub-goals are directed at the production of quality software, including good implementations of data structures and algorithms. The article focuses on discussing design go
13 min read
Language Evaluation Criteria Language evaluation criteria in programming languages are sets of standards and principles used to assess the quality and effectiveness of programming languages. These criteria are used to evaluate the features, design, syntax, and semantics of programming languages in order to determine their suita
7 min read
Coding Standards and Best Practices for System Design Within system design we have coding standards we are required to use to make the program as efficient as possible and as easy to maintain as possible. What constitutes coding standards is highlighted in this article, together with the advantages, general rules, and the best principles relating to di
12 min read
Blog | Programming Guidelines Computer programming is a process of writing an executable computer program for accomplishing a specific computer task. Although writing the programs is an art, however, there should be some minimum guidelines that should be followed while writing programs. Name: Define the variable names as per pro
2 min read
What Is Coding and What Is It Used For? Coding is the process of designing and building executable computer programs to accomplish a specific task or solve a problem. It involves writing sets of instructions in a programming language that a computer can understand and execute. Coding is a fundamental skill in the field of computer science
6 min read
Basic Coding Problems in DSA for Beginners For any beginner looking to strengthen their skills in Data structures and algorithms (DSA), we have brought to you a collection of basic coding problems. These carefully selected problems will provide a solid foundation in fundamental concepts, helping beginners enhance their logical thinking and p
2 min read
What is a Code in Programming? In programming, "code" refers to a set of instructions or commands written in a programming language that a computer can understand and execute. In this article, we will learn about the basics of Code, types of Codes and difference between Code, Program, Script, etc. Table of Content What is Code?Co
10 min read
Coding For Everyone Course By GeekforGeeks Are you a tech geek? Yes! So, you might be interested in diving deep into coding also. But the problem is you're from a non-technical background, Right? Do not worry! GeeksforGeeks has come up with a comprehensive beginner-level course for anyone irrespective of their educational background. In this
2 min read
14 Important Coding Rules to Learn from Great Developers If you have never coded ever then you might be thinking that software development is all about writing a bunch of lines of code in some languages and then releasing it to the production level whenever it is ready. Well, this is true but partially. Ask a developer what they actually do in their day-t
9 min read
Coding Decoding Question and Answers Coding decoding is an important part of the Quantitative Aptitude section in most of the competitive examinations in India. Coding and decoding questions are a common feature in the reasoning ability section of major Government exams such as those conducted by banks, insurance companies, SSC, and RR
3 min read