Hacker News new | past | comments | ask | show | jobs | submit login

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"




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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: