On Fri, 12 Mar 2010, Aristotle Pagaltzis wrote:

I’m sure you can already imagine where this is going: basically,
you should check your own intermediate computed values, to ensure
you don’t propagate error conditions sideways between parts of
your own code. But if you operate on user input directly, and the
operation can blow up, you can leave that input unchecked for the
purposes of error reporting.

(You might of course still want to check it for other reasons, eg.
security. That’s a different matter.)

Another good reason to check it is to provide a good error message. For example, "division by zero at line 116" is much less useful than "the foo parameter to the frabble() method must be a positive integer".


-dave

/*============================================================
http://VegGuide.org               http://blog.urth.org
Your guide to all that's veg      House Absolute(ly Pointless)
============================================================*/

Reply via email to