没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
C++ Coding Standards: 101
Rules, Guidelines, and Best
Practices
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
1
Table of Contents
1. C++ Coding Standards: 101 Rules, Guidelines, and Best Practices ......................................... 18
2. Table of Contents .................................................................................................................... 19
3. Copyright ................................................................................................................................. 36
4. The C++ In-Depth Series .......................................................................................................... 37
4.1 Titles in the Series ............................................................................................................. 38
5. Preface .................................................................................................................................... 39
5.1 How to Use This Book ....................................................................................................... 39
5.2 Coding Standards and You ................................................................................................ 40
5.3 About This Book ................................................................................................................ 41
5.4 Acknowledgments............................................................................................................. 42
6. Organizational and Policy Issues ............................................................................................. 43
6.1 Chapter 0. Don't sweat the small stuff. (Or: Know what not to standardize.) ................ 43
6.1.1 Summary .................................................................................................................... 43
6.1.2 Discussion .................................................................................................................. 43
6.1.3 Examples .................................................................................................................... 44
6.1.4 References ................................................................................................................. 45
6.2 Chapter 1. Compile cleanly at high warning levels .......................................................... 45
6.2.1 Summary .................................................................................................................... 45
6.2.2 Discussion .................................................................................................................. 45
6.2.3 Examples .................................................................................................................... 46
6.2.4 Exceptions .................................................................................................................. 48
6.2.5 References ................................................................................................................. 48
6.3 Chapter 2. Use an automated build system ..................................................................... 48
6.3.1 Summary .................................................................................................................... 48
6.3.2 Discussion .................................................................................................................. 48
6.3.3 References ................................................................................................................. 49
6.4 Chapter 3. Use a version control system ......................................................................... 49
6.4.1 Summary .................................................................................................................... 49
6.4.2 Discussion .................................................................................................................. 50
6.4.3 Exceptions .................................................................................................................. 50
6.4.4 References ................................................................................................................. 50
6.5 Chapter 4. Invest in code reviews .................................................................................... 50
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
2
6.5.1 Summary .................................................................................................................... 50
6.5.2 Discussion .................................................................................................................. 51
6.5.3 References ................................................................................................................. 51
7. Design Style ............................................................................................................................. 51
7.1 Chapter 5. Give one entity one cohesive responsibility .................................................. 52
7.1.1 Summary .................................................................................................................... 52
7.1.2 Discussion .................................................................................................................. 52
7.1.3 Examples .................................................................................................................... 53
7.1.4 References ................................................................................................................. 53
7.2 Chapter 6. Correctness, simplicity, and clarity come first ............................................... 53
7.2.1 Summary .................................................................................................................... 54
7.2.2 Discussion .................................................................................................................. 54
7.2.3 Examples .................................................................................................................... 54
7.2.4 References ................................................................................................................. 55
7.3 Chapter 7. Know when and how to code for scalability .................................................. 55
7.3.1 Summary .................................................................................................................... 55
7.3.2 Discussion .................................................................................................................. 55
7.3.3 References ................................................................................................................. 57
7.4 Chapter 8. Don't optimize prematurely ........................................................................... 57
7.4.1 Summary .................................................................................................................... 57
7.4.2 Discussion .................................................................................................................. 57
7.4.3 Examples .................................................................................................................... 58
7.4.4 Exceptions .................................................................................................................. 59
7.4.5 References ................................................................................................................. 59
7.5 Chapter 9. Don't pessimize prematurely ......................................................................... 59
7.5.1 Summary .................................................................................................................... 59
7.5.2 Discussion .................................................................................................................. 59
7.5.3 References ................................................................................................................. 60
7.6 Chapter 10. Minimize global and shared data ................................................................. 60
7.6.1 Summary .................................................................................................................... 60
7.6.2 Discussion .................................................................................................................. 60
7.6.3 Exceptions .................................................................................................................. 61
7.6.4 References ................................................................................................................. 61
7.7 Chapter 11. Hide information .......................................................................................... 61
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
3
7.7.1 Summary .................................................................................................................... 62
7.7.2 Discussion .................................................................................................................. 62
7.7.3 Exceptions .................................................................................................................. 62
7.7.4 References ................................................................................................................. 62
7.8 Chapter 12. Know when and how to code for concurrency ............................................ 63
7.8.1 Summary .................................................................................................................... 63
7.8.2 Discussion .................................................................................................................. 63
7.8.3 References ................................................................................................................. 65
7.9 Chapter 13. Ensure resources are owned by objects. Use explicit RAII and smart
pointers ................................................................................................................................... 65
7.9.1 Summary .................................................................................................................... 66
7.9.2 Discussion .................................................................................................................. 66
7.9.3 Exceptions .................................................................................................................. 67
7.9.4 References ................................................................................................................. 67
8. Coding Style ............................................................................................................................ 68
8.1 Chapter 14. Prefer compile- and link-time errors to run-time errors.............................. 68
8.1.1 Summary .................................................................................................................... 68
8.1.2 Discussion .................................................................................................................. 68
8.1.3 Examples .................................................................................................................... 69
8.1.4 Exceptions .................................................................................................................. 70
8.1.5 References ................................................................................................................. 70
8.2 Chapter 15. Use const proactively ................................................................................... 70
8.2.1 Summary .................................................................................................................... 70
8.2.2 Discussion .................................................................................................................. 70
8.2.3 Examples .................................................................................................................... 71
8.2.4 References ................................................................................................................. 72
8.3 Chapter 16. Avoid macros ................................................................................................ 72
8.3.1 Summary .................................................................................................................... 72
8.3.2 Discussion .................................................................................................................. 72
8.3.3 Examples .................................................................................................................... 73
8.3.4 Exceptions .................................................................................................................. 73
8.3.5 References ................................................................................................................. 74
8.4 Chapter 17. Avoid magic numbers ................................................................................... 74
8.4.1 Summary .................................................................................................................... 74
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
4
8.4.2 Discussion .................................................................................................................. 74
8.4.3 Examples .................................................................................................................... 74
8.4.4 References ................................................................................................................. 75
8.5 Chapter 18. Declare variables as locally as possible ........................................................ 75
8.5.1 Summary .................................................................................................................... 75
8.5.2 Discussion .................................................................................................................. 75
8.5.3 Exceptions .................................................................................................................. 76
8.5.4 References ................................................................................................................. 76
8.6 Chapter 19. Always initialize variables ............................................................................. 76
8.6.1 Summary .................................................................................................................... 76
8.6.2 Discussion .................................................................................................................. 77
8.6.3 Examples .................................................................................................................... 77
8.6.4 Exceptions .................................................................................................................. 78
8.6.5 References ................................................................................................................. 78
8.7 Chapter 20. Avoid long functions. Avoid deep nesting .................................................... 78
8.7.1 Summary .................................................................................................................... 79
8.7.2 Discussion .................................................................................................................. 79
8.7.3 Exceptions .................................................................................................................. 79
8.7.4 References ................................................................................................................. 80
8.8 Chapter 21. Avoid initialization dependencies across compilation units ........................ 80
8.8.1 Summary .................................................................................................................... 80
8.8.2 Discussion .................................................................................................................. 80
8.8.3 References ................................................................................................................. 81
8.9 Chapter 22. Minimize definitional dependencies. Avoid cyclic dependencies ................ 81
8.9.1 Summary .................................................................................................................... 81
8.9.2 Discussion .................................................................................................................. 81
8.9.3 Exceptions .................................................................................................................. 82
8.9.4 References ................................................................................................................. 82
8.10 Chapter 23. Make header files self-sufficient ................................................................ 83
8.10.1 Summary .................................................................................................................. 83
8.10.2 Discussion ................................................................................................................ 83
8.10.3 Examples .................................................................................................................. 83
8.10.4 References ............................................................................................................... 84
剩余278页未读,继续阅读
资源评论
- ji_ji_0012013-08-23写好C++代码必看的教材。是从Chm生成的,不过总比没有目录的好。
- 孤舟独钓2014-03-04很好的书籍,可以锻炼一下英语!
sjiagc
- 粉丝: 7
- 资源: 53
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功