Better Code: Contracts in C++
summary
Concrete C++ mechanics and tradeoffs land quickly: a zip_vector example shows preconditions, postconditions, and class invariants and the cost of checking them; exception semantics get classified as no-throw / strong / minimal guarantees and used to decide when to restore invariants or make objects discardable; some contract checks are feasible only for testing and some invariants force weaker APIs; the workflow emphasizes reviewing contracts first and code second as the practical route to safer, maintainable C++.
AI-written summary · about
chapters (22)
- 0:00Welcome
- 1:30Documentation vs code
- 4:20Origins of contracts
- 10:05Zip Vector example
- 13:43Post-condition checks
- 16:57API contract strength
- 23:22Broken invariants
- 24:04Exceptions via contracts
- 30:05Error handling in C++
- 36:54Theory of exceptions
- 37:15Zip Vector interface
- 40:49Code vs documentation
- 45:25Contracts in code review
- 46:30Contract checks limits
- 49:01Q&A: Implicit contracts
- 51:09Q&A: Human language vs code
- 52:17Q&A: Composing contracts
- 55:55Q&A: Abstraction layers
- 57:41Q&A: Debugging with contracts
- 1:00:31Q&A: Machine-checkable contracts
- 1:01:52Q&A: Documentation as contract
- 1:04:46Closing remarks
related talks
01h 11mPragmatic Simplicity - Actionable Guidelines To Tame Cpp Complexity
51mSimplicity: Not Just for Beginners
01h 02mHow to Hide C++ Implementation Details
06mLightning Talk: Best Practices Every C++ Programmer Needs to Follow
52mThe Code is Documentation Enough
50mThe Code is Documentation Enough
33mThe Catcher in the Code
56mC++ Code Smells
