C Coding Standards

What Are Coding Rules and Guidelines?

Coding rules and guidelines ensure that software is:

  • Safe: It can be used without causing harm.
  • Secure: It can’t be hacked.
  • Reliable: It functions as it should, every time.
  • Testable: It can be tested at the code level.
  • Maintainable: It can be maintained, even as your codebase grows.
  • Portable: It works the same in every environment.

 Why Apply Coding Standard?

There are four key benefits of using coding standards:

  • Reduce Code Bugs
  • Improve Code Readability
  • Ease Code Review process
  • Easy to Maintain
  • Cost Efficient

General Principles 

  • Explicit is better than implicit. 
  • Be consistent. 
  • It is easier to prevent a bug than to find it and fix it. 
  • Write as if you are writing for someone else to use and maintain code. 
  • Use C99. 
  • Avoid proprietary compiler language keyword extensions. 
  • Avoid complicated statements. 
  • Use 4 spaces per indent level.

Leave a Comment

Your email address will not be published. Required fields are marked *