About coding standards

Some software developers and software development managers uphold and practice the principle of using the compiler as a coding standard. Whatever is accepted by the compiler is good enough, as far as the style is concerned. There are variants, as the compiler may have warnings levels, and some require that the code is accepted by several versions of the same compiler, or by the compilers of several vendors, or even by every possible compiler, i.e. by the language standard.

Some other people, instead, uphold and practice the principle of applying some additional coding standards, not required by any compiler. For example, there may be capitalization rules for identifiers (all-upper-case, all-lower-case, camel-casing, etc.), indentation rules for control structures (functions, “if” statements, “while” statements, etc.), spacing rules (e.g.: “Insert a blank before and after every binary operator”), performance rules (e.g.: “Never raise exceptions or allocate heap memory except during program start-up”).

The biggest problem regarding coding standards is that, like in everyday life, also in software development rules tend to be ignored if there is no check policy to enforce them.

One way to enforce a coding rule is to add it to the software review process of the code. Well, if there is a software review process. Some developers do no software review, and some others do it when they are not under pressure, but omit it when under a deadline. But even human software review is not as sharp as a software tool. This happens for two reasons:

  • Errare umanum est. Computers are less error-prone than humans.
  • If a rule is for humans, it may be somewhat vague. If it is for a computer, it must be mathematically well-defined.

Therefore, I think that no rule should be imposed, if the software building chain does not include a software tool that automatically checks that all the written software respect that rule.

On the other side, coding rules are quite useful, and therefore I think that the software building chain should include one or more software tools that automatically check the written software for all the coding rules that is reasonable to apply.

Unfortunately, such tools are little used, and (perhaps as a consequence) are quite expensive.


About Carlo Milanesi

I am a software developer in Italy. I have develop financial, engineering and commercial software using many programming languages, mainly C, C++, Visual Basic, Java, and C#. Now I am interested in Rust and TypeScript.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s