logo       

Re: distinguishing between failures and errors: msg#00118

java.junit.user

Subject: Re: distinguishing between failures and errors

> Hmmm...just to jump in the middle for a
> second...personally, I dislike unchecked exceptions.
> I used to like them, because, similar to your
> experience, you could ignore them and not have the
> ripple effect when refactoring. However, I've seen
> this as an excuse to completely ignore the exception,
> in both testing and production. Don't like that at
> all.

I agree, but at some point, you have to trust the people doing the work to do
the work. If they ignore exceptions both in tests and in production, then
perhaps you need to replace them. :)

> So, I've decided to knuckle down and NOT use
> unchecked exceptions whenever possible. This *forces*
> you to handle them.

I don't like the patterns that checked exceptions compel me to use: converted
exception, and so on... it all sounds like jumping through hoops just to
satisfy the compiler. My job is to make tests run, dammit, not to make the
compiler happy!

> That fact that you say using them allows the compiler
> to 'get in the way' sounds like a non-issue.

"sounds like"? With respect, do you *know* that it is a nonissue? (If so, how
do I make it go away?!) For me, it *is* an issue; otherwise, I wouldn't feel
so strongly.

I want to let exceptions propagate as much as possible, because exceptions
represent situations where my code has to throw up its hands and say, "Man, I
can't go any further." In most cases, that's unrecoverable within the layer
and I want to propagate the exception up to the caller. In that case, checked
exceptions couple the caller to callee unnecessarily at compile time.

Yes, the caller needs to be aware of and handle the exception; however, I'm
not convinced that the compiler is the only way to achieve that. We've
managed quite nicely without the compiler's help and I'm happy with the
results. Again: that's what tests are for and that's why code is written by
humans and not automatically generated.

> Is this
> coupling between your two systems? Maybe...but I
> (personally) would rather have it and make damn sure
> those exceptions are handled.

What fear are you addressing by using checked exceptions? Since it is
possible to get along without them, you may be afraid of something in order
to want to use them. What might that be? (Please help me; I sound like Ron.)

--
J. B. Rainsberger,
President, Diaspar Software Services
Let's write software that people understand.
http://www.diasparsoftware.com/
telephone: +1 416 791-8603



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise