Monday, July 25, 2011

[android-developers] Re: Curious NPE

> By now, it's pretty much universally accepted that checked exceptions were
> a bad idea. An exception is an exception, and you either handle it or you
> let it propagate up the stack. The whole checked/unchecked divide is hugely
> artificial.

OK, not wanting to start a flame war, but that's not true.
If you know how to use checked Exceptions then they are a boon. Same
for unchecked Exceptions.

The problem lies in developers and APIs making very poor decisions
regarding their usage.


To answer Zsolt's question:

A checked Exception needs to be either dealt with or rebadged to fit
the paradigm of the calling class. If it can't be dealt with and your
class is now in a non-functional state consider rebadging it to an
unchecked Exceptions such as IllegalStateException.

An unchecked Exception should generally only be caught (if then) at
the very top of the process hierarchy, such as from a Thread that
needs to ensure that it doesn't fail inappropriately. Otherwise they
are best left for the UncaughtExceptionHandler to deal with (which
normally means your app crashes and whatever error reporting channel
is in place is invoked).

William

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate