NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
dying is good (Score:2)
In general, with my recent modules I've been trying to adopt a consistent behavior of "die on mutation, die on bad params, return false on accessor".
In other words, if you try to mutate/construct an object in an illegal way, it throws an exception. If a method takes parameters and you pass invalid parameters, it dies. If you try to simply retrieve some information that isn't available, it returns false.
This is, IMHO, a pretty sensible way to do things. If you try to do something impossible, it dies. If you pass in bad data, it dies. These are both _exceptional_ conditions, and merit a big reaction. OTOH, if you simply ask for data that can't be provided, I figure it's up to you to check the return value and handle the "no data" case however you see fit.
Reply to This