| Once the
need for coding standards is accepted, the organization
is faced with the problem of how to enforce them. Our
compliance analyzers automatically enforce coding standards.
Without the use of tools like ours, there is little
choice for the software development engineer but to
perform manual coding reviews in minute detail or simply
spot check the code.
Our services are ideal for performing this role since
typically more than 80% of coding standard rules are
automatically enforced by the tool. For example, naming
checks such as correct use of Hungarian Notation (if
mandated) or simple checks like maximum line length
are handled, saving the engineer the laborious, inefficient
effort of manually validating the code.
For more information refer to Compliance Analyzers.
More about coding standards ...
Coding standards are key project / company procedure
documents comprising numerous rules, a few examples
are:
Enforcing a subset of the C / C++ language to prevent
use of error prone constructs
- Dangling else
- Accidental use of = when intending = =
- Evaluation order of expressions
- Side effects
- Sequence points. . .
Deliberate limiting of use of language features for
safety critical applications and formal methods
Maximizing portability
Maximizing maintainability
Satisfying quality and safety criteria
Enforcing a uniform style
- Layout
- Identifier naming and case depending on usage
- Annotation comments
- Presence of comments (e.g. headers)
Allowing code to be easily scanned to generate documentation
etc.
Typical coding standard rules:
- Program text shall not exceed 80 columns in width.
- Use the C++ comment delimiters "//".
Do not use the C comment delimiters "/* ... */".
- Ensure each identifier is distinct.
- Include multiple inclusion guard in header files
to handle multiple inclusions of the same file.
- Declare all static objects in an anonymous namespace.
- Do not apply the following operators to signed
operands: shift operators (<<, >>), bitwise
AND (&), exclusive OR (^), inclusive OR (|) and
bitwise complement (~).
- Use initialization instead of assignment in constructors.
- Do not mix signed and unsigned data items in the
same expression.
- Do not assume the order of evaluation of operands
in an expression.
- Remove non-local static object initialization problems
by embedding in simple function or using the Singleton
pattern.
- Do not code side effects into the right-hand operands
of logical operators && and || or the size
of operator.
- Do not perform assignments inside conditional statements.
- Do not cast to a pointer of a fundamental type
to a pointer to a more restrictively aligned fundamental
type.
- Follow each flow control primitive (if, else, while,
for, switch case statements and do) by a block enclosed
by braces, even if the block is empty or contains
only one line.
- Do not return from a function a reference or a
pointer to an automatic variable defined within the
function. Instead, the function should return a copy
of the object.
- Write a virtual destructor for all base classes.
- Do not invoke virtual methods of the declared class
in a constructor.
- Avoid using const casts.
- Do not allow variable names to hide other variable
names in a wider scope.
- Do not allow the number of possible data paths
through a function to become excessive.
|