Defensive Programming Done Right, Part II
summary
Library-level defensive checks are implemented as three assertion levels (optimized ≲5% cost, regular ≈5–20%, expensive >20%), selectable per build or via overrides (e g -D BSLS_ASSERT_LEVEL), with a global callback allowing handlers like failAbort failThrow or spin/sleep; mixed-mode builds are possible but can violate the one-definition rule; a negative-testing harness injects out-of-contract calls, captures a test exception with file/line/text and verifies the handler ran; source and utilities live on GitHub and the design runs in production at Bloomberg.
AI-written summary · about
chapters (17)
- 0:00Intro
- 3:06How do we as an enterprise decide what to do?
- 5:35High-Level Requirements
- 10:17Ex. 1 (Client): Using failAbort (by default)
- 14:44Library): Using BSLS_ASSERT_SAFE
- 20:16Soft Undefined Behavior is Relative
- 25:47Library): Using BSLS ASSERT IS ACTIVE
- 33:44Client): Creating a custom handler.
- 34:16Client): Installing/Invoking custom handler.
- 37:59Motivating example: Sorted Order
- 39:18Client): Using BDE_BUILD_TARGET_SAFE_2
- 39:44Build-Mode Summary
- 46:51What is a Test Driver?
- 47:12What is the Command-Line Interface/Contract?
- 51:24For negative testing to be successful
- 54:08Plan (FOR EACH TEST DRIVER)
- 58:06Constructors present a unique problem
related talks
33mDefensive Programming at cURL
01h 01mBack to Basics: Debugging and Testing in C++ Software Development
01h 12mWriting robust code
01h 40mTesting, Preconditions, Coverage and Templates in Safety-Critical C++ Code
01h 01mBack to Basics: Debugging in Cpp
54mBuild Safer Modern C++ Application: Mix Assertion, Logging, Unit Testing and Fuzzing with ZeroErr
25mThe Art of Defensive Programming
01h 34mKeynote: Contracts, Testing & the Pursuit of Well Defined Behaviour
