C++ Coding Standards and Style Guide

Ground Software Systems Branch Code 583 
Originally Developed by Wendy Shoan and Linda Jun (Code 583)

Modified for the General Mission Analysis Tool (GMAT) Project by 
Linda Jun & Wendy Shoan(Code 583) Last Updated: 2012/02/16

1. Introduction


This document is based on the "C Style Guide" (SEL-94-003). It contains recommendations for C++ implementations that build on, or in some cases replace, the style described in the C style guide. Style guidelines on any topics that are not covered in this document can be found in the "C Style Guide." An attempt has been made to indicate when these recommendations are just guidelines or suggestions versus when they are more strongly encouraged.
Using coding standards makes code easier to read and maintain. General principles that maximize the readability and maintainability of C++ are:

  • Organize classes using encapsulation and information hiding techniques.
  • Enhance readability through the use of indentation and blank lines.
  • Add comments to header files to help users of classes.
  • Add comments to implementation files to help maintainers of classes.
  • Create names that are meaningful and readable.
1.1 Purpose 

This document describes the Ground Software Systems Branch's recommended style for writing C++ programs, where code with "good style" is defined as that which is

  • Organized
  • Easy to read
  • Easy to understand
  • Maintainable
  • Efficient
1.2 Audience

This document was written specifically for programmers developing applications for mission support, although the majority of these standards are generally applicable to all environments. This document is intended to help programmers to produce better quality C++ programs by presenting specific guidelines for using language features.

1.3 Interpretation

This document provides guidelines for organizing the content of C++ programs and files. The guidelines are intended to help programmers write code that can be easily read, understood, and maintained. This document also discusses how C++ code can be written more efficiently.
The term "method" means a function that is a member of a class. The term "Class Interface" means a class declaration in the header file. The term "Class Implementation" means a class definition in the source file.

  • No labels