Coding in Software Engineering
Coding is the process of converting a system’s design into a computer-readable programming language. During this phase of software development, the design specifications are translated into source code. Along with the code, proper internal documentation is written so that the correctness of the implementation can be easily verified against the original design.
Coding is usually carried out by programmers or coders who are different from the system designers. The main objective of coding is not merely to reduce development effort or cost at this stage, but to minimize expenses in later phases of the software life cycle. Well-structured and efficient coding helps reduce the cost of testing and makes software maintenance easier and more effective.
Goals of Coding
1. Translate system design into code
Coding involves converting the system design into a computer programming language that can be executed by a computer. The written code performs tasks according to the specifications defined during the design phase.
2. Reduce the cost of later development stages
Efficient and well-structured coding helps reduce the cost of testing and maintenance in later phases of the software development life cycle.
3. Improve program readability
The program should be easy to read and understand. Good readability improves code comprehension and helps developers maintain and modify the software more easily.
Characteristics of programming language
1. Readability
A good high-level language allows programs to be written in a way that closely resembles natural English. This enables self-documenting code that is easy to read and understand.
2. Portability
High-level languages are mostly machine-independent, making it easier to develop software that can run on different hardware platforms.
3. Generality
Most high-level languages support a wide range of applications, reducing the need for programmers to learn multiple specialized languages.
4. Brevity
The language should allow algorithms to be implemented using fewer lines of code. Programs written in high-level languages are usually shorter than those written in low-level languages.
5. Error Checking
Programmers often make errors during development. High-level languages provide error-checking mechanisms at both compile time and run time to detect bugs early.
6. Cost
The overall cost of using a programming language depends on several factors, including development, maintenance, and execution efficiency.
7. Quick Translation
The language should support fast compilation or interpretation to reduce development time.
8. Efficiency
It should allow the generation of efficient object code that makes optimal use of system resources.
9. Modularity
The language should support modular programming, enabling programs to be developed as separate, well-structured modules that ensure consistency and ease of maintenance.
10. Wide Availability
A good programming language should be widely available, with translators and tools supported across major hardware platforms and operating systems.
Coding Standards
A coding standard defines a set of rules and guidelines to be followed while writing code. These rules include naming conventions for variables, code layout, error-handling practices, and documentation styles.
General coding standards describe how developers should write code, regardless of the programming language used. Following these standards improves code readability, consistency, and maintainability.
1. Indentation
Proper and consistent indentation is essential for creating programs that are easy to read and maintain. Indentation should be used to:
- Highlight the body of control structures such as loops and selection statements
- Emphasize the blocks of conditional statements
- Clearly indicate new scope blocks
2. Inline Comments
Inline comments should be used to explain the working of subroutines and important parts of the algorithm. They help improve code understanding and maintenance.
3. Rules for Using Global Variables
Clear rules should be defined to specify which types of data can be declared as global and which should not. This helps reduce errors and improves program clarity.
4. Structured Programming
Structured or modular programming practices should be followed. The use of GOTO statements should be avoided, as they lead to unstructured or “spaghetti” code that is difficult to read and maintain, except where explicitly permitted by specific language standards.
5. Naming Conventions
Consistent naming conventions should be followed for identifiers. For example:
- Global variables may start with capital letters
- Local variables may use lowercase letters
- Constants may be written entirely in uppercase letters
6. Error Return Conventions and Exception Handling
Error handling methods should be standardized across the program or organization. For instance, all functions should consistently return a specific value (such as 0 or 1) to indicate success or failure, ensuring uniform error reporting.
Coding Guidelines
General coding guidelines provide programmers with a set of best practices that help make programs easier to read, understand, and maintain. Although many examples use C language syntax, these guidelines can be applied to most programming languages.
The following are some common coding guidelines recommended by many software development organizations.
1. Line Length
It is a good practice to limit the length of each source code line to 80 characters or less. Longer lines may not display properly on some terminals and tools, and certain printers may truncate lines exceeding this limit.
2. Spacing
Proper use of spaces within a line of code improves readability and clarity.
Example:
Bad:
cost=price+(price*sales_tax)
fprintf(stdout ,"The total cost is %5.2f\n",cost);
Better:
cost = price + ( price * sales_tax );
fprintf(stdout, "The total cost is %5.2f\n", cost);
3. Code Documentation
The code should be well documented. As a general guideline, there should be at least one comment line for every three lines of source code.
4. Function Length
The length of a function should ideally not exceed 10 source lines. Long functions are harder to understand, often perform multiple tasks, and are more prone to errors.
5. Avoid goto Statements
The use of goto statements should be avoided because they make programs unstructured and difficult to read and maintain.
6. Inline Comments
Inline comments should be used where necessary to explain important statements and improve code readability.
7. Error Messages
Error handling is an important part of programming. In addition to detecting and handling errors, error messages should be clear and meaningful so that users and developers can easily understand the problem.


