Page History
...
| Tabsetup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3.1 General Coding Standard GuidancePlanning for the adoption and use of coding standards at the beginning of a software development activity sets the right tone and approach for the development team. Software coding standards are classified by language, usage, and severity levels.
Correlations between bugs and coding practices resulted in rules that helped prevent coding errors from occurring. These activities resulted in recommendations to develop and use coding standards. In a team environment or group collaboration, the use of coding standards ensures uniform coding practices and reduces oversight errors and the time spent in code reviews. When NASA software development work is outsourced to a supplier (see 7.03 - Acquisition Guidance), having a set of coding standards in place helps ensure that the 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 that 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). See also PAT-022 - Programming Practices Checklist, 3.2 How Coding Standards are ClassifiedSoftware coding standards are classified by language, usage, and severity levels. Industry experts determine Language-specific rules and best coding practices in that particular language. 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.
3.3 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 - Software Peer Reviews and Inspections for Requirements, Plans, Design, Code, and Test Procedures), and assessments of how the coding standards are used to develop the software work products. See also Topic 7.10 - Peer Review and Inspections Including Checklists. 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. 3.4 MISRA and CERT-C Coding Standards
See also SWE-023 - Software Safety-Critical Requirements, SWE-157 - Protect Against Unauthorized Access, SWE-185 - Secure Coding Standards Verification, 3.5 How to Interpret the "and/or" Phrase in the Requirements StatementThe "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. 3.6 Checklists Relevant To LanguagesThe checklists below contain specific checks and things to be aware of in certain languages:
3.7 Additional GuidanceAdditional guidance related to this requirement may be found in the following materials in this Handbook: Related Links | Include Page | SWE-061 - Related SWEs | SWE-061 - Related SWEs | Include Page | SWE-061 - Related SM | SWE-061 - Related SM | 3.8 Center Process Asset LibrariesExcerpt Include | SITE:SPAN | SITE:SPAN | nopanel | true | See the following link(s) in SPAN for process assets from contributing Centers (NASA Only). SPAN Links | Include Page | SITE:SPAN Code and Integration | SITE:SPAN Code and Integration |
Div | | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| refstable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Show If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Panel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Expand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SWEREFs to be added | SWEREFS to be deleted |
| Children Display |
|---|
Software coding methods, standards, and criteria form the foundation of a consistent, maintainable, and reliable software development process. Establishing and enforcing these principles ensures code quality, promotes collaboration, supports regulatory compliance, and minimizes risks during software development and maintenance lifecycle phases. Below are detailed reasons that justify the rationale for this requirement: 1. Ensuring Code Consistency
2. Improving Software Quality
3. Facilitating Collaboration and Integration
4. Supporting Standards Compliance and Certification
5. Enhancing Code Maintainability
6. Supporting Automation and Tooling
7. Reducing Project Risks
8. Supporting Reuse of Software Components
9. Reducing Defect Rates Early in Development Cycle
10. Meeting Safety and Security Requirements
Examples of Coding Standards and GuidanceTo implement and enforce this requirement, the project manager should select appropriate coding methods, standards, and criteria such as:
ConclusionThis requirement ensures that the project manager formally selects, defines, and enforces best practices and standards for the software development process. Doing so ensures that the software meets its intended requirements with high reliability, safety, and maintainability. By fostering consistency, improving quality, reducing risks, and supporting compliance, adherence to coding methods, standards, and criteria is essential to the success of NASA’s software-intensive missions. |
| Div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3. GuidanceNASA programs and projects have multi-year life cycle times. Often the software personnel who develop the original software work products move on to other projects. These developers are then backfilled on the team by other developers for the remainder of the development, operations, maintenance, and disposal phases of the life cycle. This personnel turnover process may occur several times during the project's life cycle. The use of uniform software coding methods, standards, and/or criteria ensures uniform coding practices, reduces errors through safe language subsets, and improves code readability. Verification that these practices have been adhered to reduces the risk of software malfunction for the project during its operations and maintenance phases. See also SWE-060 - Coding Software, There are five key benefits of using coding standards:
Coding standards help prevent or reduce unsafe coding practices such as defect-prone coding styles, security issues from specific coding sequences, and numerous coding errors, mistakes, and misunderstandings.
1. Importance of Coding Standards in NASA ProjectsLongevity of ProjectsNASA programs and projects often span decades across their life cycles, including development, deployment, operation, maintenance, and eventual retirement. During this time:
Key Benefits of Coding StandardsAdhering to coding standards provides significant benefits, particularly in NASA's software development context, where safety, reliability, and security are paramount:
Certification and Critical SoftwareFor NASA’s human-rated and mission-critical hardware, adherence to a recognized coding standard (e.g., MISRA-C, CERT C) and the use of automated static analysis tools are industry best practices. Manual verification of large-scale systems is impractical, making automated verification against coding standards essential to detect vulnerabilities and ensure compliance. 2. General Coding Standard GuidancePlanning for Coding Standards
Key Distinction: Coding Standards vs. Coding Style
Correlation With Defect Prevention
Outsourcing ConsiderationsWhen software development is outsourced, having clear coding standards ensures contractors deliver high-quality code that meets NASA’s requirements. Standards should:
3. Practical Guidelines for Coding StandardsClassification of StandardsCoding standards are commonly classified by:
Essential Coding Standard CoverageStandards should cover the following aspects:
4. Tools and Automated VerificationRole of Automation
Recommendations for Automated Analysis
5. Verification and AssessmentVerification Activities
Training
Legacy and Human-Rated Software
6. Example Standards and References
Documentation of Standards
7. ConclusionThis guidance highlights the essential role of coding methods, standards, and criteria in NASA’s software development processes. Their adoption ensures high-quality, secure, reliable, and maintainable software, critical to mission success. In practice:
See also SWE-023 - Software Safety-Critical Requirements, SWE-157 - Protect Against Unauthorized Access, SWE-185 - Secure Coding Standards Verification, See SWE-087 - Software Peer Reviews and Inspections for Requirements, Plans, Design, Code, and Test Procedures), and assessments of how the coding standards are used to develop the software work products. See also Topic 7.10 - Peer Review and Inspections Including Checklists. See also PAT-022 - Programming Practices Checklist 3.6 Checklists Relevant To LanguagesThe checklists below contain specific checks and things to be aware of in certain languages:
3.7 Additional GuidanceAdditional guidance related to this requirement may be found in the following materials in this Handbook:
3.8 Center Process Asset Libraries
See the following link(s) in SPAN for process assets from contributing Centers (NASA Only).
|
| Div | ||
|---|---|---|
| ||
4. Small ProjectsFor small projects, the scope, budget, and timeline are typically more constrained than large-scale endeavors. However, adhering to coding methods, standards, and criteria is equally critical to ensure software reliability, maintainability, and security. The following simplified guidance is tailored for small projects to streamline the process while maintaining quality and compliance. 1. Start Simple: Use Existing Standards and ToolsLeverage Established Standards
Use Tools for Automation
2. Tailor Standards to Small Project NeedsFocus on Essential Rules
Keep It Lightweight
3. Planning and IntegrationSet Expectations Early
Low Overhead for Compliance
4. Ensure Traceability to Project GoalsAlign With Project Requirements
Traceability Practices
5. Efficient Verification and TestingStatic Code Analysis
Peer Reviews (Lightweight)
6. Security Considerations for Small ProjectsAdopt Secure Coding Practices
Use Minimal Tooling
7. Practical Example for Small ProjectsImagine a small team working on a Python project to control a science instrument. Adopting Standards
Verification Process
Delivering Results
8. Final Recommendations for Small Projects
By following these streamlined recommendations, small projects can effectively apply Requirement 4.4.3, ensuring consistency, reliability, and maintainability without unnecessary overhead. These practices support the successful completion of small-scale development efforts while ensuring compliance with NASA standards and best practices. |
| Div | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||
5. Resources5.1 References
5.2 Tools
|
| Div | ||||
|---|---|---|---|---|
| ||||
6. Lessons Learned6.1 NASA Lessons LearnedLessons Learned from NASA’s History with Coding StandardsThe NASA Lessons Learned database provides key insights into the importance of coding standards based on prior mission experiences. These lessons underscore the role of coding standards in ensuring maintainability, cost control, and error reduction in projects across the software development lifecycle. The following entries from the database provide critical lessons for implementing coding standards effectively: 1. Software Design for MaintainabilityLesson Number 0838
2. Mars Pathfinder Flight Software Development Process (1997)Lesson Number 0590
3. Static Software Analysis of the NASA Autonomous Flight Termination SoftwareLesson Number 24503
Key Application of Lessons Learned to Small and Large ProjectsThese historical lessons emphasize NASA's ongoing focus on the importance of disciplined and consistent coding practices. Regardless of project size, the following actions should be taken to incorporate these lessons effectively:
Integrating Lessons Learned into Current NASA ProjectsUsing the lessons from past projects, the following procedural steps can help integrate coding standards effectively into NASA projects:
Examples of Common Lessons to Implement in PracticeLesson/Application: For projects reusing code from prior missions:
Lesson/Application: When adopting static analysis tools:
Lesson/Application: Early identification of coding inconsistencies:
Key TakeawaysCombining insights from the NASA Lessons Learned database with modern practices allows project managers to ensure coding standards are not just a set of rules, but a valuable tool for improving software quality, reducing costs, and ensuring mission success. Leveraging these insights will create a robust foundation for the continued success of NASA’s software systems across their extended life cycles. 6.2 Other Lessons LearnedThe Goddard Space Flight Center (GSFC) Lessons Learned online repository
|
| Div | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||
7. Software Assurance
7.1 Tasking for Software Assurance
7.2 Software Assurance ProductsStatic Analysis of the Source Code
Independent Evaluation of Source Code
Key Deliverables for SA Verification of Code Against Coding Standards
7.3 MetricsEffective metrics support continuous improvement and provide a quantitative way to track adherence to coding standards and resolution of issues. Recommended Metrics for Coding Standards
Reference:For additional metric-related guidance, see Topic 8.18: SA Suggested Metrics. 7.4 Updated GuidanceTask 1: Understand and Familiarize With Project Coding Standards
Task 2: Perform Independent Static Code Analysis
7.5 Recommendations for Success
By rigorously implementing and independently verifying adherence to coding standards, software assurance ensures that the project minimizes risks, improves maintainability, and upholds NASA’s emphasis on delivering high-quality software systems. 7.6 Additional GuidanceAdditional guidance related to this requirement may be found in the following materials in this Handbook:
|
| Div | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||
8. Objective Evidence
|
5.2 Tools
| Div | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
6. Lessons Learned6.1 NASA Lessons LearnedThe NASA Lessons Learned database contains the following lessons learned related to coding standards:
6.2 Other Lessons LearnedNo other Lessons Learned have currently been identified for this requirement. |
| Div | ||||
|---|---|---|---|---|
| ||||
7. Software AssuranceExcerpt Include | | SWE-061 - Coding Standards | SWE-061 - Coding Standards | |
| Panel | ||||
| ||||
| Include Page | SITE:SWE-061 - SA Task1 | SITE:SWE-061 - SA Task1 | ||
| Include Page | SITE:SWE-061 - SA Task2 | SITE:SWE-061 - SA Task2 |
| Note | ||
|---|---|---|
| ||
|
| title | Definition of objective evidence |
|---|
7.3 Metrics
- # of coding standard violations identified (Open, Closed, type of violation, Severity)
- # of software process Non-Conformances by life cycle phase over time
See also Topic 8.18 - SA Suggested Metrics
7.4 Guidance
Task 1: Review the project software development/management plan to learn what kind of software coding standards, methods, rules, and principles are used for the project. The coding standards could include any project-defined standards that dictate the safe use of code, secure coding standards, reliability coding standards, etc. They may also include a set of “principles” or best practices that have been collected for particular software applications, such as principles for developing flight software. These coding standards and principles are reviewed by software assurance during the development and selection of the project processes, as per SWE-013 - Software Plans. After becoming familiar with these standards, practices, and principles, analyze the software code using the static analyzers' results to help determine whether these standards, methods, and principles are being used consistently. Any risks or issues should be brought up with project management.
Task 2: Software assurance will perform independent static code analysis on the coding standard practices, methods rules, and principles. They should review the results of the static code analysis runs to determine whether the project's coding standards, etc., are being followed. Results should be reported to the project management at the end of the analysis. Information on code standard usage, static code analysis tools, their effectiveness, and the developers’ responses to the results should also be shared with the project management.
7.5 Additional Guidance
Additional guidance related to this requirement may be found in the following materials in this Handbook:


