Coding standards (also known as coding conventions) are guidelines for programming languages that dictate methods, practices, and styles for programs written in a specific programming language. Coding standards cover include things like naming conventions, indentation, file organization, programming practices and principles, etc.
Coding standards are used to ensure that all developers working for an organization or on a project follow the same structure and guidelines. This way all code involved in the project can be understood and maintained with ease by everyone involved, not just the developer who wrote the code. The use of standards also enables developers to reuse code from one project to another.
Using coding standards can also improve security. Inconsistencies, bugs, and logical errors can cause vulnerabilities in the software. Most of these problems are caused by poor coding practices. With clean well written code, it is also easier to find and fix any errors that may occur.
Even though most organizations have their own specific coding standards or style guides, some fall back on the World Wide Web Consortium’s (W3C) guidelines. W3C is an international community where people from all around the world work together to develop standards. Both Google and WordPress recommend that developers run their HTML code through the W3C HTML validator. Despite the fact that the use of the validator is recommended, passing validation does not necessarily mean that the code is up to the standards of any specific organization. The validator will catch many errors but there is no substitute for reviewing your code manually.
Coding standards may vary depending on the organization. For example, Google’s coding standards dictate that indentation is to be done with 2 spaces instead of tabs:

where WordPress coding standards ask that tabs be used for all indentation.

Another example of differences between organizations is that WordPress wants its developers to close all self-closing tags with a forward slash that has a space before it:

But AB Tech’s guidelines ask that similar elements not be closed.

Since there are differences between organizations, it is important to familiarize yourself with the standards of the organization you are working for.
While coding standards are not necessary for a website or program to run, I still believe that they should be used. They make writing and maintaining the code easier, and make things more secure by removing vulnerabilities.
Leave a comment