Page History
...
| Tabsetup | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"A comprehensive coding standard encompasses all aspects of code construction. ...Properly completed source code reflects a harmonized style as if a single developer wrote the code in one session. At the inception of a software project, a coding standard is established to ensure that all developers are working in concert. When the software project incorporates existing source code or performs maintenance on an existing software system, the coding standard states how to deal with the existing codebase. "The readability of source code has a direct impact on how well a developer comprehends a software system. Code maintainability refers to how easily that software system can be changed to add new features, modify existing features, fix bugs, or improve performance. Although readability and maintainability are the results of many factors, one particular facet of software development upon which all developers influence is the coding technique. One of the easiest methods to ensure a team of developers will yield quality code is to establish a coding standard, which is then enforced at routine code reviews".
Over time, correlations between bugs and coding practices resulted in rules that helped prevent coding errors from occurring.
In a team environment or group collaboration, the use of coding standards ensures uniform coding practices, reduces oversight errors and the time spent in code reviews. When NASA software development work is outsourced to a supplier (see Topic 7.3 - Acquisition Guidance), having a set of coding standards in place helps ensure that the contractor's code meets quality requirements mandated by NASA in the NASA Software Assurance Standard, NASA STD 8739.8.
A coding standard document may be written as a general document that is independent of any project. Project-specific needs are then added as amendments to the document. Note there is an important difference between a coding style and a coding standard. A coding style specifies how you indent lines or employ tabs and spaces to make the code easier to read by the software development team. A coding standard, which often includes a coding style, goes beyond just how to name a variable. It tells you how that variable is to be treated and when it is to be used (and not used).
One way to tell the difference between a coding style and a coding standard is to assess the functionality of code changed due to applying the coding style or standard. If the coding style was not followed, the code should still work the same way, with the same behavior and safety checks. However, if the coding standard is not correctly applied, the code's "safety" and/or functionality have likely changed. A coding standard is more important than a coding style since the standard affects the code's behavior. How Coding Standards are Classified Software coding standards are classified by language, usage, and severity levels. Industry experts determine Language-specific rules and best coding practices in that particular language. The user sets usage types and severity levels.
Coding standards should address (for all the languages used):
The following items may be an integral part of the coding standard to the extent their implementation affects the execution of the software. Otherwise, they are part of the coding style.
Adherence and Verification
Assuring the developed software's adherence to the coding standards provides the greatest benefit when followed from software development inception to completion. Coding standards are selected at the start of the software development effort. Verification activities of the software work products include reviews, such as peer reviews and inspections (see SWE-087), and assessments of how the coding standards are used to develop the software work products. Automated tools for assessing adherence to standards at appropriate reviews, or even on a batch mode run overnight, will assist the project team in adherence and verification. Training should be provided for the software development team to use the logic model checkers for the analysis and verification of flight software.
Manual analysis to verify the complete application of safety or security coding standards is all but impossible.
MISRA and CERT-C Coding Standards
Two example coding standards to improve safety, reliability, and security in software systems are MISRA, and CERT C.MISRA C has become the de facto standard for embedded C programming in safety-related industries and is also used to improve software quality even where safety is not the main consideration. How to Interpret the "and/or" Phrase in the Requirements Statement The "and/or" in the text of the requirement statement is meant for flexibility in tailoring the requirement to the project's needs. Inappropriate (e.g., less "critical") settings, a subset of ”methods, standards, criteria” would be sufficient and compliant. For human-rated applications, the project would want to cover methods, standards, and criteria (e.g., the use of the Klocwork® Insight tool as part of the method, MISRA C (a software development standard for the C programming language developed by MISRA (Motor Industry Software Reliability Association) as part of the standards, avoidance of the project's restricted language constructs as criteria, etc.). NASA-specific coding standards information and resources are available in Software Processes Across NASA (SPAN), accessible to NASA users from the SPAN tab in this Handbook. Additional guidance related to the planning and control of software coding standards and where they may be used may be found in the following related requirements in this Handbook:
|
...


