Needs of Coding Standards
- Maintainable
- Proper understanding format / Readable
- Comments / Documentation
- Maintaining the changes done
- Reusable
- For doing a project we need a set of people in a set of teams, if everyone have perceptive to do code, then there will problems while integration of all the code (which all-together makes project). Hence the "Coding Standard" is needed.
- The time takes to understand the code must be less. Hence the source and comments must be easy and effective.
- If some code needs to modify or some new features needed to be added, for that the code clear(maintainable).
Coding Standards
Alignment
- Indentation is required.
- The tab size should be 4.
- The space is required after the function name and before parenthesis.
- After comma there should be a space.
- Within the square bracket there should not be any space.
- Use more parenthesis even if it is simple.
- The curly braces should be used in the following format for the conditions, constructors and loops.
if (condition) {
....
} else {
....
}
- The singe blank lines are required for the following :
- including files
- critical area
- block
- conditions and loops
- The double lines are required for the function.
- Declaring function
- Template : action_performed_verb
- The way to write a function :
function perform_addition ()
{
...
}
Naming
- Variable and function names can be in the combination of words.
- G_ is used for global variables declaration.
- The local variables should be shorter.
- T_ is used for temporary variables.
- The name should be meaningful, it should says it purpose.
- Proper naming must be there.
- Name separation must be done with an underscore("_").
- There can only 3 underscores at the max.
- For macros the capital letters are used.
- The parenthesis must be given, even if in some of languages its optional :
if ( ( ( (condition) || (condition) ) && (condition) ) )
- Files
- Not only the variables and function names must be meaningful, but also the filenames should be proper.
- The file name can have the following :
- project_name
- sub_name
- purpose of file name
- Max
- 15 to 25 functions per file.
- 1000 lines of file
- One page scrollable code.
Comments
- 15 to 25 functions per file.
- 1000 lines of file
- One page scrollable code.
- Explanation
- Understanding
- Sample input and output
- Logical algorithm
- Function header
- File header
- Declaration usage
- Where form, where to
- Special Note
- REMIND
- TODO
- CAUTION
- NOTES -> important values, notes
Credits and References
https://woz-u.com/blog/the-evolution-of-coding-what-programming-languages-are-prominent-today/

No comments:
Post a Comment