3 ms·
My 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
by kc0bfv 14y ago
My 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.