C++ Coding Standards
C++ Coding Standards
Summary:
Introduction
The book "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices" was published in 2004, but it remains one of the most authoritative reference guides on C++ code style and quality. The authors — Herb Sutter and Andrei Alexandrescu — are recognized experts in the C++ world, whose names are associated with a deep understanding of the language and practical advice. This book does not teach syntax — it teaches you to think like a professional C++ developer.
What is this book about?
The book is a collection of 101 rules grouped into thematic sections. Each rule is accompanied by a brief rationale, examples (often with "bad" and "good" versions), and references to more in-depth sources. Main topics:
- Code Organization — proper use of header files, namespaces, avoiding circular dependencies.
- Class and Interface Design — SOLID principles, RAII idiom, Pimpl, the rule of zero/five.
- Resource and Memory Management — safe use of smart pointers, avoiding leaks, working with exceptions.
- Templates and Generic Programming — how to write efficient and portable templates.
- Performance — optimization tips without sacrificing readability.
- Exception Safety — basic, strong, and nothrow guarantees.
Who is this book for?
The book is intended for programmers already familiar with the basics of C++. Beginners will find it difficult — the authors do not explain basic constructs but immediately move on to nuances. The ideal reader is a developer who wants to transition from the level of "writing working code" to the level of "writing robust, efficient, and easily maintainable code."
What will the reader learn?
- How to avoid 90% of common mistakes when working with memory and exceptions.
- Why
std::vectoris often better thanstd::list, even if it seems the opposite. - How to design interfaces so they are hard to use incorrectly.
- When to use virtual functions and when to use templates.
- How to write code that doesn't "crash" on exceptions.
- Why
constis not just a modifier, but a design tool.
Strengths of the book
1. Practical focus. Each rule is a ready-made recipe that can be immediately applied in a project. No abstract theory — only what really works.
2. Author authority. Sutter and Alexandrescu are not just theorists; they actively participated in C++ standardization and compiler development. Their advice is proven by years of practice.
3. Compactness. 240 pages — not a "brick" that is scary to open. The book can be read in a week and then used as a desktop reference.
4. Connection to other sources. After each rule, there are references to more detailed materials: books by Scott Meyers, articles in C++ Report magazine, the language standard. This is an excellent starting point for further study.
5. The language hasn't aged. Despite being from 2004, 90% of the rules are still relevant for C++17/20. Some recommendations (e.g., avoiding std::auto_ptr) have become history, but the authors warn about this.
Who is it recommended for?
The book is a must-read:
- Developers working with C++ in production — especially in finance, games, and high-load systems.
- Team leads and architects who want to establish unified code standards in their team.
- Advanced students studying C++ in depth.
- Anyone transitioning from C to C++ who wants to avoid "C with classe