Practice question · Multiple choice
An invariant checker is written, run during development, and deleted before release. What was gained, and what was lost?
Hints
- Ask when the checker earns its keep: while the code is being written, or after it ships?
- Deleting and compiling out have the same runtime effect. What differs?
Show the answer
C. Bugs caught where they were caused, at no production cost
Why
The value is entirely in development, where it converts a distant symptom into an immediate one, so a released build loses nothing by omitting it. Compiling out rather than deleting keeps it available for the next change, which is exactly what assertion mechanisms are for.
Practise Debugging Structural Invariants
The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Debugging Structural Invariants
- Order the steps of debugging a data structure with an invariant checker.
- Sort each statement about a binary search tree by whether it is an invariant of the structure.
- Select every benefit the lesson attributes to writing an invariant checker.
- An invariant checker is code that verifies a structure's rules and is never called in production. Why is…