>
> http://www.ckwop.me.uk/Why-Exceptions-Suck.html
>

"Checked exceptions are certainly better than unchecked exceptions" !!!

Java had checked exception but its successors (C#) removed this feature. 
The designers of Java libraries have moved away from checked exceptions too 
(the presence of checked exceptions is a good way to know how old a library 
is). So I would not take this blog article as an authoritative source on 
exceptions.

Structured exception handling makes it possible to build very robust 
systems with very little error handling code. But you need a methodology. 
Mine is based on "software contracts" (a lvariant of B Meyer's original 
formulation, without retry). Behind every function that you write there is 
some kind of contract (usually tacit but you can make it explicit with 
pre/post conditions). If your function fullfils its contract it should 
return normally; if it cannot fullful it (for whatever reason), it should 
throw. If you follow this simple rule (the difficulty is not in the rule 
but in clarifying what your contracts are) you'll design robust systems 
with very little exception handling code. You'll throw a lot and you'll 
just have a few try/catch in strategic places. And try/finally will be your 
best friend: it will allow you to release resources and maintain invariants.

This works well when your code is written in sync style, and it generalizes 
well to future/promises (exceptions, if any, are thrown where you wait on 
futures). But it is not manageable with callbacks everywhere.

Bruno

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/703d84fc-d2f9-4ec3-b2c6-a5694b50e614%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to