Coding Standards
Introduction
Programming style (also called code standards, style guides or code convention) is a term that describes conventions for writing source code in certain programming languages.
The programming style depends on the programming language that has been chosen to program, that is, each language can have different conventions but each language has its own.
Style Features
Appropriate variable names
A key piece to good style is the appropriate choice of variable names "Variable (programming)"). Poorly named variables make it difficult to read and understand the source code.
As an example, consider the following pseudocode excerpt:.
Due to the choice of variable names, it is difficult to realize the function of the code.
Compare now with the following version:.
The intent of the code is now easier to discern, "given a time in 24 hours, true will be returned if it is valid and false if not."
Indentation style
Indentation style"), in programming languages that use curly braces "Key (punctuation)") to indent or delimit logical blocks of code, such as C, is also a key point of good style. Using a logical and consistent style makes one's code more readable. Compare:.
or:
with something like:
The first two examples are much easier to read because they are well indented, and the logical blocks of code are grouped and represented together more clearly.
Boolean values in decision structures
Some programmers think that decision structures like the ones above, where the decision result is merely a computation of a Boolean value, are too verbose and even prone to error.
They prefer to make the decision in computing by themselves, like this: