Production C++ code often hides small but deeply complex algorithms inside layers of engineering: APIs, lifetimes, error handling, integration, logging, and glue code. We test classes and systems, but rarely the algorithm itself in isolation.
Off-by-one errors and broken or missing invariants can survive extensive pre-production testing. Line coverage does not imply branch coverage. Branch coverage does not imply coverage of algorithmic corner cases. Testing through a wide public API often obscures the mathematical structure of the problem, making subtle bugs difficult to discover through multiple layers of abstraction.
This talk explores how to extract an "algorithmic core" from a larger component. Its correctness is fundamentally mathematical and largely language-agnostic rather than C++-specific.
Using examples such as substring matching, topological sorting variations, and lazy evaluation on trees, we will examine how problem corner cases differ from implementation corner cases, and how easily some of them are skipped.
We will discuss:
- Recognizing when an algorithm is entangled with boilerplate
- Extracting core logic without introducing accidental complexity
- What it takes to test algorithmic code in isolation
- Raising the level of abstraction to make reasoning easier without merely relocating complexity
- Using LLMs to assist in exploring and validating implementations
- Gradual rollout and comparison of competing implementations