********************************************************************************
General Principles
1 Adhere to the style of the original
2 Adhere to the Principle of Least Astonishment
Simplicity Clarity Completeness Consistency Robustness
3 Do it right the first time
4 Document any deviation
********************************************************************************
Formatting Conventions
5 Use indented block statements
6 Indent statements after a Label
7 Choose one style for brace placement
8 Break long statements into multiple lines
Step One: Introduce a line break after each comma.
Step Two: Introduce a line break just before the operator with the lowest precedence.
9 Include White Space
10 Do Not Use "Hard" Tabs
********************************************************************************
Naming Conventions
11 Use UPPERCASE and Underscores for Preprocessor Macro Names
12 Add a Unique Prefix to Macro Name
13 Use "UpperCamelCase" for Classes, Constants, Structures, Enumerations, and Typedefs
14 Use Nouns to Name Compound Types
15 Use "lowerCamelCase" for Function Names
16 Use Verbs to Name Functions
17 Pluralize the Names of Collections
18 Use "is", "set", and "get" to Name Accessor and Mutator Functions
19 Use "lowerCamelCase" for Variable and Function Parameter Names
20 Use Nouns to Name Variables
21 Add a Prefix or Suffix to Member Variable Names to Distinguish Them from Other Variables
22 Name all Function Parameters
23 Use "other" for Parameter Names in Copy Constructors and Assignment Operators
24 Give Function Parameters the Same Name as the Member Variables You Assigned Them to
25 Use Meaningful Names
26 Use Familiar Names
27 Avoid the Use of Digits within Names
28 Avoid Excessively Long Names
29 Join the Vowel Generation--Use Complete Words
30 Use "lowerCamelCase" for Abbreviations
31 Do Not Use Case to Differentiate Names
********************************************************************************
Documentation Conventions
32 Document Your Software Interface for Those Who Must Use It
33 Document Your Implementation for Those Who Must Maintain It
34 Keep Your Comments and Code Synchronized
35 Embed Application Program Interface Reference Documentation in Your Source Code
36 Generate API Reference Documentation Directly from the Source Code
37 Document all Significant Software Elements
38 Document Software Elements as Early as Possible
39 Use Block Comments to Describe the Programming Interface
40 Use One-Line Comments to Explain Implementation Details
41 Use a Single Consistent Format and Organizationfor All Documentation Comments
42 Provide a Summary Description of Every Declared Element
43 Document the Interface Exposed by Every Function
44 Document Thread Synchronization Requirements
45 Provide Examples to Illustrate Common and Proper Usage
46 Document Important Preconditions, Postconditions, and Invariant Conditions
47 Document Known Defects and Deficiencies
48 Use the Active Voice to Describe Actors and Passive Voice to Describe Actions
49 Use "this" Rather Than "the" When Referring to Instances of the Current Class
50 Explain Why the Code Does What It Does
51 Avoid the Use of End-Line Comments
52 Label Closing Braces in Highly Nested Control Structures
53 Add a "fall-through" Comment between Two case Labels if no break Statement Separates Those Labels
54 Use Keywords to Mark Pending Work, Unresolved Issues, Defects, and Bug Fixes
********************************************************************************
Programming Principles
55 Do Not be Afraid to Do Engineering
56 Choose Simplicity over Elegance
57 Do Not Use a Feature of C++ just "because it is there"
58 Recognize the Cost of Reuse
59 Program by Contract
60 Keep Classes Simple
61 Define Subclasses So They May be Used Anywhere Their Superclasses May be Used
The Liskov Substitution Principle
The Open-Closed Principle
62 Use Inheritance for "is a" Relationships and Containment for "has a" Relationships
63 Avoid Multiple Inheritance
64 Design for Reentrancy
65 Use Threads only Where Appropriate
To simultaneously respond to many events
To provide a high level of responsiveness
To take advantage of machines with multiple processors
66 Avoid Unneccessary Synchronization
67 Do Not Synchronize Access to Code That Does Not Change Shared State
********************************************************************************
Programming Conventions
68 Use '#include"..."' for Collocated Header Files
and '#include<...>' for External Header Files
69 Place Preprocessor Include Guards in Header Files
70 Use #if .. #endif and #ifdef .. #endif Instead of "/*...*/" Comments to Hide Blocks of Code
71 Use Macros Sparingly
72 Add a Semicolon after Every Statement Expression Macro
73 Use Macros to Capture the Current File Name and Line Number
__FILE__ , __LINE__
74 Do Not Use "#define" to Define Constants
Declare Static Const Variable Instead
75 Use Portable Types for Portable Code
76 Use Typedefs to Simplify Complicated Type Expressions
77 Create a Zero-Valued Enumerator to Indicate an Uninitialized, Invalid, Unspecified, or Default State
78 Do Not Define Enumerations Using Macros or Integer Constants
79 Declare Enumerations within a Namespace or Class
80 Declare Global Functions, Variables, or Constants as Static Members of a Class
81 Declare for-loop Iteration Variables Inside of for Statements
82 Use an Enumeration Instead of a Boolean to Improve Readability
83 Use an Object Pointer Instead of a Reference if a Function Stores a Reference or Pointer to the Object
84 Accept Objects by Reference and Primitive or Pointer Types by Value