Enforcing Component Constraints
Cantor, Scott
cantor.2 at osu.edu
Thu Jan 26 19:47:57 EST 2017
On 1/26/17, 6:56 PM, "dev on behalf of Brent Putman" <dev-bounces at shibboleth.net on behalf of putmanb at georgetown.edu> wrote:
> It was a Chad-ism I guess (and IIRC maybe also an Ian-ism?), but I don't really disagree with it. In the absence of any
> automagical constraint enforcement, it's better to me to get a fatal error with some contextual info, rather than just a
> naked fatal NPE.
My point is it still incurs the small cost of a null check. To me the point of it all is to skip the cost by assuming the caller is to blame for doing it wrong.
It's case by case whether the result of a check is an unchecked or checked error or a return code, but it's all the same to me, it's assuming the caller isn't going to do it right.
So, I would actually drop the checks and live with an NPE because I don't really need the context, the stack trace is going to tell me the line, same information I get from the exception message.
But if we're going to raise unchecked errors, sure, automating it is better.
-- Scott
More information about the dev
mailing list