Back to Basics: Abstractions
summary
Walks through a concrete C++ example: a sensor that writes 16‑byte measurements to three sinks (buffer, stats, file) and shows how replacing three loops with a single write-record abstraction reduces cognitive load while preserving performance because the compiler can inline and eliminate overhead in this case (measured 0–4 ns overhead, real-call cost a few percent on his machine). Recommends three-layer contract tests (concept/compilation, shared contract tests, implementation-specific checks), warns of three common failures—leakage, overconstraint, overgeneralization—and advises using concrete types until multiple implementations or callers exist.
AI-written summary · about
chapters (16)
- 0:00Introduction and setup
- 1:06Why abstractions matter
- 3:58Abstraction examples in code
- 8:47Naming as abstraction
- 10:11C++ abstraction mechanisms
- 12:01Abstract classes vs concepts
- 14:55Choosing abstraction tools
- 15:58Why now for abstractions
- 17:06Contract specifications
- 18:34Testing abstraction contracts
- 20:19Runtime abstraction impact
- 21:44Common abstraction failures
- 26:02Checking existing contracts
- 27:26Contract validation checklist
- 29:13When to abstract
- 29:35Closing and recommendations
