Coding Practices Coding Standards
Coding Practices Coding Standards
Coding Standards
01 What is Coding?
02 Goals of Coding
CONTENTS
03 Coding Practices
04 Coding Standards
01
Coding in Software Engineering?
01 What is Coding?
Coding:
1 2 3
To translate the design
of system into a To reduce the cost Making the program
computer language of later phases more readable
format
It increases code
The coding is the process of The cost of testing
understanding having
transforming the design of a and maintenance can
readability and
system into a computer be significantly
understandability as a clear
language format, which can be reduced with
objective of the coding
executed by a computer and efficient coding.
activity can itself help in
that perform tasks as specified
producing more maintainable
by the design of operation
software.
during the design phase.
02 Goals of Coding
Portability Modularity
Brevity Efficiency
7
03
Coding Practices
03 Coding Practices
Coding Practices?
In the software engineering community, standardized coding conventions help keep the
code relevant and useful for clients, future developers, and the coders themselves. Any
professional programmer will tell you that the majority of their time is spent reading
code, rather than writing it. You are more likely to work on existing code than to write
something from scratch. So it’s important that your code is easy to understand for
other engineers.
Best Practices that will help to write production-level code and ultimately make you a
better developer are:
10
03 Coding Practices
In order to optimize your code, you need to make sure it executes the
function quickly Because In the world of software engineering,
writing code quickly and correctly is pointless if the end product is
slow and unstable.
12
03 Coding Practices
There are a number of principles that will help you develop an effective
coding style. Some of them are:
Using version control in a professional project will give you the following
benefits:
In case your system crashes, the entire code is backed up on the server.
All members of the software engineering team can sync their changes
regularly by downloading them from the server.
Numerous developers can work independently to add/remove features or
make changes to a single project, without impacting other member’s work.
If serious bugs are created, you can always return to a previous, stable
version of the codebase that was known to work.
14
03 Coding Practices
Testing ensures the code gives the desired result and meets all necessary
user requirements.
Unit tests are used to test small, self-contained parts of the code logic.
These engineering tests are designed to cover all possible conditions.
The process of writing the test is beneficial in itself. It requires you to figure
out the behavior of your code and how you’re going to test it.
Small and regular tests are better than one large test after completion. This
approach helps maintain a modular structure and will result in a higher
quality end product.
15
03 Coding Practices
The keyword here is “Simple,” and the idea is to keep your code as
concise as possible. In the context of coding, this means making your
code meaningful, to-the-point, and avoiding unnecessary engineering
work.
The KISS Principle ensures that your code has high maintainability. You
should be able to go back and debug it easily, without wasting time
and effort.
16
03 Coding Practices
17
03 Coding Practices
General Tips
Some tips and techniques can be applied to any coding language and are
useful in improving the overall quality of your code:
18
04
Coding Standards
04 Coding Standards
Coding Standards
A coding standard gives a uniform appearance to
the codes written by different engineers.
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:
3. Naming conventions for local variables, global variables, constants and functions
4. 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.
04 Coding Standards