Coding PDF
Coding PDF
The coding is the process of transforming the design of a system into a computer
language format. This coding phase of software development is concerned with
software translating design specification into the source code. It is necessary to
write source code & internal documentation so that conformance of the code to
its specification can be easily verified.
Coding is done by the coder or programmers who are independent people than
the designer. The goal is not to reduce the effort and cost of the coding phase, but
to cut to the cost of a later stage. The cost of testing and maintenance can be
significantly reduced with efficient coding.
Goals of Coding
Brevity: Language should have the ability to implement the algorithm with less
amount of code. Programs mean in high-level languages are often significantly
shorter than their low-level equivalents.
A coding standard lists several rules to be followed during coding, such as the
way variables are to be named, the way the code is to be laid out, error return
conventions, etc.
Coding Standards
General coding standards refers to how the developer writes code, so here we will
discuss some essential standards regardless of the programming language being
used.
Coding Guidelines
General coding guidelines provide the programmer with a set of the best methods
which can be used to make programs more comfortable to read and maintain.
Most of the examples use the C language syntax, but the guidelines can be tested
to all languages.
1. Line Length: It is considered a good practice to keep the length of source code
lines at or below 80 characters. Lines longer than this may not be visible properly
on some terminals and tools. Some printers will truncate lines longer than 80
columns.
2. Spacing: The appropriate use of spaces within a line of code can improve
readability.
Example:
Bad: cost=price+(price*sales_tax)
fprintf(stdout ,"The total cost is %5.2f\n",cost);
4. The length of any function should not exceed 10 source lines: A very
lengthy function is generally very difficult to understand as it possibly carries out
many various functions. For the same reason, lengthy functions are possible to
have a disproportionately larger number of bugs.