Exception Handling (when to use it)

Andy Armstrong andy at hexten.net
Fri Jul 13 08:59:01 BST 2007


Ovid wrote:
> Side note:  some Java programmers who understand exceptions may still be leery about using them for things that Perl programmers wouldn't because in Java, exceptions can be very expensive to throw and catch (the reasons were explained in detail to me once, but I was too stupid to remember it).  Keep that in mind if you ask Java programmers about exceptions.

I've seen the 'hack' of looping over a string or array and relying on
the ArrayIndexOutOfBounds (or whatever it's called) exception to break
out of the loop in more than one Java program.

I suppose it's quite neat if it's isolated to something really
performance critical - but I worked with a guy who'd cargo culted from
that to 'if you don't do it that way your loop is hideously inefficient
and you are an idiot'. He accused me of 'not knowing Java very well'
because I didn't use it *all the time* :)

-- 
Andy Armstrong, Hexten


More information about the london.pm mailing list