Wouldn't it be better if we could create programs that were correct by construction (and thus needed no assertions)?
Wouldn't it be better if we could create programs that were correct by construction (and thus needed no assertions)?
It is a shame when that happens, but when it does, it's not the fault of the rules, it's the fault of the organizational culture. The rules would still be valuable if you used them thoughtfully and with the aim of improving the reliability of the product, not gaming some management system.
With the exception of assert(ptr != NULL) assertions, I think most of the ones I've hit have actually been completely duff, and with some thought could just be removed. I dread to think what would happen if I grepped the commit histories of all the projects I've worked on for "removed duff assert".
Assertions are not meant to be needed. Any bug-free programm should behave exactly the same with and without assertions.
On the other hand, in any sufficiently complex algorithm, asserting the pre- and postconditions generally helps readability, maintainablilty and correctness.