Coding to demonstrate the importance of coding standards,

 

Coding standards, sometimes referred to as programming
styles or coding conventions, are a very important asset to programmers.
Unfortunately, they are often overlooked by junior as well as some program
developers due to the fact that many of the recommended coding standards do not
actually affect the compilation of the code itself, a concept that we will
focus on later. This report shall try to demonstrate the importance of coding
standards, and why they have already become a common practice for businesses
and programming language developers alike.

I shall begin with a definition of coding standards. In
general they are a set of standards and guidelines which are/should be used
when writing the source code for a program.  Standards are rules which a developer is
expected to follow. However these rules, such as “the compiled file must have
the extension .h” are often apparent are followed anyway. Guidelines however are
much less well followed. They are stylistic measures which have no direct
affect on the compilation of the guide, and exist only to make the source code
more humanly readable. They are optional, but highly recommended.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

An important thing to remember about coding standards that many
programmers seem to forget is that coding standards are not an abstract idea.
In fact, for many companies and practically all programming languages, a coding
standard is a physical document, and is vital for producing uniform code.

Coding standards vary in importance between companies and
programming languages. For the COBOL programmer for example, commenting code
(an area of coding standards which will be explained later) would be
significantly less important than in other languages, as it is possible to make
COBOL self documenting. It also may not be important for a company that is not
going to be continually producing software and it may be more time consuming
than just building the software without. However, in open source software, the
importance of coding standards cannot be emphasised enough. The most prominent
example of this is Mozilla Firefox, the open source internet browser which
makes all its code freely available online. This is so other developers can
look over the source code, possibly identifying possible security flaws/bugs in
the code as well as extending the code. It would be extremely difficult for
other developers to identify potential flaws in the program if it did not
follow a particular style convention. Also, Firefox has a huge database of
extensions, some of which it created itself but many of which were created by
external developers. External extensions would be very difficult to understand
and integrate into Firefox if they did not follow a coding standard, and
Firefox may not have been such a popular internet browser as it is today.

Coding standards, when implemented correctly, can provide
huge advantages to the produced code and the companies implementing them. They
can make a great difference when maintaining software. Maintenance is arguably
the most important step in the Software Development Life Cycle (SDLC) and is
definitely the most recurring. When the developers who are responsible for
maintaining the code are different from the ones who produced it, it relies on
them understanding code developed by another developer. With the lack of a
coding standard, this task would be extremely different because the majority of
programmers have their own programming style which is often difficult to follow
by anyone with the exception of the original developer. Having a coding
standard however, means that all software programmers will be easily able to
read and understand all the code for a program, as long as it conforms to the
coding standard and the developer who is maintaining the code is familiar with
it, making it easily maintained and modify if needed.

Software that complies with a pre-existing coding standard
has also been proven to contain fewer bugs and generally be of a higher
quality. This is because the software is much easier to test, and any potential
errors or problems with the code can be fixed in the development process of the
program. Since the cost of fixing a bug in a program increases exponentially
over time it is important to catch such bugs in the early development process
to save money. This is, however, not the only way having a coding standard can
save money for a company. Having a pre-existing coding standard that the
developers are already familiar with can speed up the overall software
development process, get the product to market faster, possibly making more
money for the company. Also, as discussed earlier, software developed to a
coding standard contains less bugs which means less time and money has to be
spent maintaining the code.

Complying with a coding standard can also have a huge effect
on teamwork. Often, programmers learn to program in different ways and have
varying, often conflicting programming styles. This can cause conflict within a
development team and such conflicts would certainly make the team less
efficient. Having a pre-existing coding standard however means that there are
no discrepancies as to how the program should be designed. Another way in which
teamwork is affected is the ability to team switch i.e. have other programmers
working on other projects transfer into other development groups. Having a
company-encompassing coding standard means that developers can be switched from
different parts of the company and require very little training to begin
programming in other teams. This complements critical path analysis, a business
technique which identifies the areas of a project which, if delayed, would
delay the entire project. If such areas are identified, then developers can be
easily assigned to such areas, ensuring the project is finished on time.

There are two main types of coding standards, coding
standards written for a company, and coding standards written for a programming
language. The company coding standard is what developers are expected to follow
within the company, whereas the coding standard for a programming language is
what the programming language developers recommend all programmers should follow.
Often, both contain a lot of similar points, and for companies that only
program in one language, both are often almost identical. However for companies
which develop software in a variety of languages, they often formulate their
own coding standard. For example, Mozilla Firefox is written in C++, XUL, XBL,
and JavaScript. Instead of inefficiently using the four separate coding
standards of each language, Mozilla has created its own coding standard.

 

 

 

 

 

Examples

In each coding standard, there are many points and rules.
For example, the coding standard for GNU’s Not Unix (GNU) (an open source
operating system) is 88 pages long. There are many points contained within such
coding standards, some of which I shall discuss here.

E.g. 1

Indentation

Indentation is discussed in all coding standards at some
level. In some languages, indentation is used by the compiler to identify the
scope of functions. In freeform languages, such as Java, it has no actual effect
on the compilation of code itself, and is just used to make the code more human
readable, giving an indication of scope without actually affecting the program
directly.

Type 1

if (g