Your method should rarely (JUnit tests, and other rare instances) 'throws Exception.'
Its just plain gross. Especially because you were a lazy ass when the only exception BEING thrown is an SQLException!
This code I'm maintaining is from an overseas job.
The only thing I can tell my boss is: You can't polish a turd
And before ya bitch, I spend all yesterday out with my son riding his bike, then afterward going out to get him ice cream, then up all night with him cause he had leg cramps (must rode too long), so I'll get to the photos late tonight (hopefully... I got training class until at least 9).
If the method is supposed to return a value do you want it to return null or some "empty value" if it fails or actually cause an Exception because you're in an exceptional state?
"thows Exception" is like saying "thows something" - if your routine throws Foo, Bar, and Baz you should declare it as throwing Foo, Bar, and Baz, so that the caller knows what exceptions to expect (and thus what to catch).
Throws a generic Exception is not an exceptionl case, because the error, java.lang.Exception, is a generic exception type. If you're in a special case, you'll probably want to trap that with its own type. Throwing Exception just says, "Something happened
wowbagger kinda explained it. I'm 100% for Exception throwing, but in java, "java.lang.Exception" is the parent of all exceptions. So if I'm throwing "SQLException" and "NumberFormatError", then both of these method declarations are compilable:
void foob
If it were not for turds found in poor code, how else would root kits steal all of our personal information? I remember back when I thought I was the shizzle for tossing around a little VBScript.... Oh how times have changed... I learned C, C++, PERL, J
I thought I splained it before. I'm in the.NET group, but still do my java work. I'll learn C# and expand my knowledge but most of the jobs I'll be doing is in Java.
The first thing they want me doing is to make a java API available in C#. So I'm like
That shipping program that I wrote actually emails me everytime it throws an exception. Why? because the shipping guys when it gave them an error that said, "X has happened, please notify IT to have this problem diagnosed before closing the window." I'd
You should be catching the exception in your highest level view class (like your actions in struts or servlets if you are doing the old-skool thang), and reporting something nice to the user and logging the actual error and stacktrace.
That's how I'm doing it now. It's catches each error type that could possibly exist and reports a custom error to the user for each one, along with what they need to do to correct it. But instead of logging it, I'm sending emails to myself and materials (
I have just been thrust into a position at my company where some java is a requirement. Since he left so suddenly, and I have proven myself with a number of other projects using php, and I also am the only one that is even slightly familiar with the syste
I have just been thrust into a position at my company where some java is a requirement. Since he left so suddenly, and I have proven myself with a number of other projects using php, and I also
Download the Eclipse IDE. Download the proper (like 1.4.2) Java SDK. Dot completion is your biggest friend and Ctrl+Space will recommend things you can do at any point. Ctrl+Click will take you to the declaration of what you're clicking. Let Eclipse compil
Kiddo finally started pedaling her tricycle on September 11, 2004. She was just a couple months shy of 4 years old. Gross motor skills are not her strong suit. Neither is speed.
I don't think it's going to take Squirt that long -- she's already eyeballing
I just learned about the banana thing. Joey loves bananas, so I'll have to get him eating those daily again... And he's a good milk drinker (at least a (kids) cup a meal), so that isn't an issue.... Thanks for the advice:-D
What would you prefer? (Score:2)
Re:What would you prefer? (Score:2)
It's about like writing a routin
Re:What would you prefer? (Score:1)
Throws a generic Exception is not an exceptionl case, because the error, java.lang.Exception, is a generic exception type. If you're in a special case, you'll probably want to trap that with its own type. Throwing Exception just says, "Something happened
Re:What would you prefer? (Score:2)
void foob
Ahh, I simply misunderstood (Score:2)
I think every Java program should have
public class oopIDied extends Exception
something else to do (Score:2)
huh. (Score:2)
Re:huh. (Score:2)
The first thing they want me doing is to make a java API available in C#. So I'm like
Re:huh. (Score:2)
Welcome to the club (Score:2)
Oh, did I mention that one of the first lines of every file is "try" and one of the last lines is "catch (Exception e)"?
I actually got to talk to th
Re:Welcome to the club (Score:2)
And when I go back to it, (IF anyone ever goes back to it) it gets taken out.
However I always log log log log logl og lgo gllo gool my exceptions b
Re:Welcome to the club (Score:2)
Re:Welcome to the club (Score:2)
You should be catching the exception in your highest level view class (like your actions in struts or servlets if you are doing the old-skool thang), and reporting something nice to the user and logging the actual error and stacktrace.
Tha
Re:Welcome to the club (Score:2)
slightly offtopic (Score:2)
oops! Re:slightly offtopic (Score:2)
Here it is again:
I have just been thrust into a position at my company where some java is a requirement. Since he left so suddenly, and I have proven myself with a number of other projects using php, and I also
Re:oops! Re:slightly offtopic (Score:2)
Re:oops! Re:slightly offtopic (Score:2)
No one to blame (Score:1)
Is Joey on a two-wheeler? Training wheels? If they're off, I'd love to know how you did it.
Re:No one to blame (Score:2)
Re:No one to blame (Score:1)
Re:No one to blame (Score:2)
I don't think it's going to take Squirt that long -- she's already eyeballing
Exceptions are ... (Score:2)
Now, everyone says "what the hell, I'll just write it and wrap it in
The Analog (Score:2)
try{
catch( Exception e )
{ System.out.println("Socket can't connect"); }
Now while there is lots of socket code, in there, it isn't the only exception throwing code, and because the exception catche
Well... (Score:2)
leg cramps (Score:2)
light stretching
problems be gone!
Re:leg cramps (Score:2)