Glossary · Automation software engineering and architecture
Coding guideline
Also known as: Programming guideline, Style guide (code)
German: Kodierrichtlinie
In software engineering, a coding guideline is a documented recommendation on how to write source code, covering for example naming, structure, comments, language features to avoid and error handling, so that code is consistent, readable and less error-prone.
- Software engineering
In one sentence
A coding guideline documents recommendations on naming, structure and language use so source code is consistent and less error-prone.
Example
The company's PLC coding guideline requires prefixes for variable scope, forbids jumps in structured text and asks for a header comment in every function block.
How it applies
- Engineering: Guidelines give developers a shared style and help avoid known pitfalls. For IEC 61131-3, published guidelines such as those from PLCopen are often used as a starting point and adapted to the company.
- Quality: Rules that can be checked automatically belong in Linting or static analysis; the rest is checked in Code review. A guideline nobody checks is quickly ignored.
- Documentation: Write guidelines like any other procedure: rule, rationale and example. The documentation team can apply its own experience with terminology and style guides, and align naming rules for tags and alarms with the terminology used in manuals.
Coding guideline vs. coding standard
The terms are often used interchangeably. Where a distinction is made, a Coding standard contains binding rules, often with a compliance process (for example MISRA C), while a guideline contains recommendations that allow justified deviations. Projects should state which rules are mandatory.