C++ Coding Standard - C++ 编程规范

C++ Coding Standard - C++ 编程规范

C++ Coding Standard
https://users.ece.cmu.edu/~eno/coding/CppCodingStandard.html

Adapted from C++ Coding Standard
http://www.possibility.com/Cpp/CppCodingStandard.html

C Coding Standard
https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html

1. Contents

1. Resources- Take a Look!
2. Names
(important recommendations below)
Include Units in Names
Class Names
Class Library Names
Method Names
Class Attribute Names
Method Argument Names
C++ File Extensions
C Function Names
(other suggestions below)
Make Names Fit
Variable Names on the Stack
Pointer Variables
Reference Variables and Functions Returning References
Global Variables
Global Constants
Static Variables
Type Names
Enum Names
#define and Macro Names
3. Formatting
(important recommendations below)
Brace {} Policy
Parens () with Key Words and Functions Policy
A Line Should Not Exceed 78 Characters
If Then Else Formatting
switch Formatting
Use of goto,continue,break and ?:
(other suggestions below)
One Statement Per Line
Alignment of Declaration Blocks
4. Classes
(important recommendations below)
Naming Class Files
Class Layout
Order of public/protected/private?
What should go in public/protected/private?
Required Methods for a Class
Method Layout
Use of Namespaces
Use Header File Guards
(other suggestions below)
Different Accessor Styles
Initialize all Variables
Think About What Work to do in Constructors
Be Careful Throwing Exceptions in Destructors
5. Documentation
(important recommendations below)
Comments Should Tell a Story
Document Decisions
Use Headers
Make Gotchas Explicit
Commenting function declarations
(other suggestions below)
Include Statement Documentation
6. Complexity Management
Layering
Delegation
Minimize Dependencies with Abstract Base Classes
Liskov's Substitution Prinicple
Follow the Law of Demeter
Miscellaneous
Be Const Correct
Use Streams
Use #if Not #ifdef
Commenting Out Large Code Blocks
Don't Over Use Operators
Short Methods
No Magic Numbers
Error Return Check Policy
To Use Enums or Not to Use Enums
Macros
The Bull of Boolean Types
Usually Avoid Embedded Assignments
Mixing C and C++
7. Miscellaneous
No Data Definitions in Header Files
Make Functions Reentrant

References

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值