4 ms·
i disagree. if my code is being called with incorrect parameters, i WANT it to blow up. if a method silently fixes input data to something it can deal with, t
by allenbrunson 19y ago
i disagree. if my code is being called with incorrect parameters, i WANT it to blow up. if a method silently fixes input data to something it can deal with, then it's hiding a bug that needs to be fixed.
also, assertions are good documentation. they let maintenance programmers a better idea of what's expected at this point.
- edw519 19y agoYes! If it causes pain, I WANT it to hurt. Has worked pretty well for us for 3 million years. The same for our code.
- Tichy 19y agoMabye I never needed them much because I have mostly been using Java, which has things like NullPointerException. So no need to write an assertion for that special case. By blow up I meant do something bad, not fail in a noisy way. That would be the exception.
- darkclark 19y agoUnit tests are the way to separate assertions from your implementation code to avoid messiness.