4 ms·
Sometimes (especially in dynamic-land) you assert stuff before doing some processing, so that stuff does not blow up halfway but upfront. "- but, it should nev
by lloeki 14y ago
Sometimes (especially in dynamic-land) you assert stuff before doing some processing, so that stuff does not blow up halfway but upfront.
"- but, it should never happen?!"
"- so, make it not happen, ever"
- kc0bfv 14y agoMy understanding is that asserts are for debugging, and exceptions/more robust error handling are for production. Asserts make the code blow up, which can make a problem easier to spot in dev/testing. In production it seems better to throw an exception, even if the program can't handle it well and just has to quit nicely. I like your defensive programming strategy - see if the tires are flat before you get out on the highway.