BOOK / SOURCE & READING RECORD
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
Herb Sutter; Andrei Alexandrescu
1st edition, copyright 2005 (published October 2004)
C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
Obtained the complete first-edition PDF and sequentially read the full text of all 101 items 0–100 (Summary, Discussion, Examples, Exceptions, and References), and inspected page by page all 80 substantive pages that contain embedded code images, filling in code blanks left by text extraction. Also cross-read official Items 1, 25, 73, 74, and 83. Summaries and the index are not counted as main text. auto_ptr, dynamic exception specifications, old-style adapters, and similar material are treated only as historical context; original examples use C++20 and do not copy old code.
Edition, actual reading range, and original sources →Sources
- Pearson official sample pages: Items 1, 25, 73, 74, 83
PDF pages 14–20; book pages 2–3, 46, 144–145, 160–161.
- Item 74: Report, Handle, and Translate Errors Appropriately
Complete online Item 74, including Summary, Discussion, Exceptions, and References.
- InformIT book and purchase page
Verified the first edition, publication date, 101-item table of contents, and official sample-page entry; not the full book text.
Stop errors at the boundary that has decision-making authority
Items 73–74, book pages 144–145; combined with Item 25, book page 46.
Discovering, translating, and handling errors are three distinct responsibilities. A parser knows which part of the input is syntactically invalid, but may not know whether to retry, prompt the user, or cancel the entire task; therefore it must not fake success just to return a number. If an upper layer is only responsible for forwarding, let the exception continue to propagate; only the place that has business context should add business meaning, and only the place that can choose a recovery action should stop the propagation. Catching by reference and a bare throw preserve the exception’s dynamic type, rather than copying and slicing information just so every layer has a catch. Modern code can also express failure with error values, but the boundary must make success and failure mutually exclusive; logging output must not be mistaken for recovery. The original example here uses parsing an amount to illustrate this division of responsibilities and does not copy the book’s cases.
Related fundamentals
Exception Safety: Guarantees, noexcept, and Commit PointsParameter passing and ownership contracts