4 ms·
I completely agree with the approach outlined in the original post. (It's also called defensive programming.) Not failing fast and hard when the application is
by js8 8y ago
I completely agree with the approach outlined in the original post. (It's also called defensive programming.)
Not failing fast and hard when the application is in unexpected state (which is what assert should check) is robust only on the surface.
I think we have the debate because it's not just about adding asserts. If you want to add asserts to existing codebase, essentially making it to fail fast and hard, you need to have a system architecture that is capable of dealing with said failure. If your codebase isn't architected as such, you will probably make things worse for the user by adding extra asserts.
I think that's what the people who are against asserts fear
of, and rightfully so. But the answer shouldn't be do not use asserts, the answer should be make the system more resilient to failure first.