See the best coding practices are only a set of informal rules that the software development community has learned over years which can improve quality of software.
The basic need of proper coding practice are:-
1. For improved readability.
As a programmer, you will be working in team and if you are not able to write code in proper way it may lead to a lot of difficulties to your team mates.
2. For better maintainability:
In case of any malfunction or change required, it is easier to implement in a well written code with proper programming practice.
3. For better debugging:
In case of any error a better written code is easier to debug.
These might seem a bit unsubstantial reason to go through the pain of writing a proper code but believe me IT companies spend more money and time on maintaining a software than its production.
Now when we know the need of a proper coding practice is, lets move forward and what
good coding practices are:-
1. Commenting and documentation:
This helps in knowing the reason and objective of writing a piece of code
for example- (focus not on content of the code,but just on the way of writing it)
2.Proper and Consistent Indentation:
This leads in improved readability.
example
3.You can avoid obvious comments.
4.Code grouping:
Certain tasks requires a few lines of code. It is a good idea to keep these tasks within separate blocks of code, with some space between them.
5.Consistent Naming Scheme:
Every language have there naming technique and more over every company have more specific naming criteria, one must follow that.
eg. camelCase for function name or underscore for variables etc.
6.Avoid very intense nesting:
eg.
7.Limit Line length
8.Maintain Proper file and folder organization:
This helps in avoiding bad dream of finding a file or including it.
9.Consistent Temporary Names:
The basic need of proper coding practice are:-
1. For improved readability.
As a programmer, you will be working in team and if you are not able to write code in proper way it may lead to a lot of difficulties to your team mates.
2. For better maintainability:
In case of any malfunction or change required, it is easier to implement in a well written code with proper programming practice.
3. For better debugging:
In case of any error a better written code is easier to debug.
These might seem a bit unsubstantial reason to go through the pain of writing a proper code but believe me IT companies spend more money and time on maintaining a software than its production.
Now when we know the need of a proper coding practice is, lets move forward and what
good coding practices are:-
1. Commenting and documentation:
This helps in knowing the reason and objective of writing a piece of code
for example- (focus not on content of the code,but just on the way of writing it)
2.Proper and Consistent Indentation:
This leads in improved readability.
example
3.You can avoid obvious comments.
4.Code grouping:
Certain tasks requires a few lines of code. It is a good idea to keep these tasks within separate blocks of code, with some space between them.
5.Consistent Naming Scheme:
Every language have there naming technique and more over every company have more specific naming criteria, one must follow that.
eg. camelCase for function name or underscore for variables etc.
6.Avoid very intense nesting:
eg.
7.Limit Line length
8.Maintain Proper file and folder organization:
This helps in avoiding bad dream of finding a file or including it.
if you are required to use a temporary variable independently many times then try to use common name following a proper pattern.
Eg. for outer loop variable use i and for inner use j and so on.
Thanks for reading this post.
Next will be about looping.




No comments:
Post a Comment