4 ms·
> Assert easily allows lazy programmers to let their programs freely crash without properly handling error conditions. This is what he meant by misuse. Proper
by PDoyle 10y ago
> Assert easily allows lazy programmers to let their programs freely crash without properly handling error conditions.
This is what he meant by misuse. Properly-used assertions are meant to document and check conditions that were thought to be impossible by the developer. Not just unlikely, or illegal, but impossible. If a condition is possible, and you check it with assert, that's a bug.
- mixedCase 10y agoThose are panic territory, which carries a different connotation than the word assert (which has very likely influenced in its very widespread misuse).
- kruhft 10y agoThe biggest problem I've seen with assert[1] is putting functioning code inside one and then not knowing why your code no longer works with NDEBUG. [1] http://en.cppreference.com/w/c/error/assert http://en.cppreference.com/w/c/error/assert
- dvirsky 10y agoI came to detest assert when I was working on a project with another guy, who used it generously, as a substitute for assertions in (non existing) unit tests. Nothing would annoy me more than working on my code, running it, and having all sorts of weird assertions pop up all over the place from this guy's code.
- deleted 10y ago[deleted]