Author | Topic |
Location: Cabramatta, NSW
Registered: May 2002
|
Re: hey java buffs
|
Tue, 06 May 2003 08:55
|
|
HKSPete wrote on Tue, 06 May 2003 17:46 | Sorry I was a bit vage. I meant your IF statement was the right way to go (you are right, I'm not dissagreeing with you), but a specific try BLOCK (its a block not a bloody "loop"!! ) for just a null pointer is silly. Which is exactly what you said in the quote.
As for elegant catches YUK. No such thing. A catch is ONLY if there is something that wasn't expected. If there is a possibility there is a null, test for it, don't expect the try block to pick it up. Putting more than e.printStackTrace() or throwing another exception within a catch block is disgusting code.
I didn't know there were this many java learners/programmers in Toymods . Just remember grasshopper(s):
Computers are a great way to make money. Money that can be spent on doing up toyotas!
|
Block, loop, you know what I meant.
I have to sneak my foruming in between work (got management snooping around) so most of my replies aren't well thought out.
I didn't say elegant catches, I meant elegant handling of thrown exceptions.
I disagree with you on the stack traces. They are evil. If you can handle an exception and can fix the problem, then do so at all costs. Stack traces are only useful if you're debugging.
And, no I don't catch NullPointerExceptions, I use the if/else blocks, but I'm not talking about null pointers specifically.
|
|
|