Journal FortKnox's Journal: "throws Exception" is not acceptable!! 27
Ugh, I hate maintaining old code.
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).
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).
What would you prefer? (Score:2)
Re:What would you prefer? (Score:2)
It's about like writing a routine as
int foo(...)
rather than
int foo(int soldiers, enum Color color)
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. I'm not telling you what happened. So go fix it." You're better off throwing an Error in those cases.
Re:What would you prefer? (Score:2)
void foobar() throws SQLException, NumberFormatException {...}
void foobar() throws Exception {...}
The second one works because of polymorphism, but the first one is still a better way of doing it. The reason is when I call the method:
foobar()
Now if I used the
Ahh, I simply misunderstood (Score:2)
I think every Java program should have
public class oopIDied extends Exception
something else to do (Score:2)
I feel your pain, yet it is that very pain that allows me to feed my younguns.
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 the "Java Guy" in the
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 the "programmer" (he sure weren't no 'developer') about what his "thinking" was behind doing this. The answer: so when the program crashes, the user won't see it. Never mind that there is no easy way to diagnose problems. Suppose the code does three SQL fun
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 because they are my lifes blood.
The WORST- was when using some package to convert a stream into xml and it dying on some subroutine called "convert character"- what character?! WTF?! My xml objects are 20K on 1 line!!! (it breaks vi)
Re:Welcome to the club (Score:2)
"Down? You can't log on?"
"I can log on, I just can't do nothun'."
"No email or internet."
"No, them's working fine."
"Ok, so tell me what ISN'T working."
"My shipping program threw up a buncha gobbledygook on
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.
That way the user knows something went wrong and (possibly) how to avoid it, and you get the exact problem so you can (possibly) fix it so it won't happen again...
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 am the only one that is even slightly familiar with the systems he was working on they figured what the heck?
That he didn't document ONE single thing coupled with the fact that I am the only other one who has ever worked on these systems made me a shoe-i
Re:oops! Re:slightly offtopic (Score:2)
Re:oops! Re:slightly offtopic (Score:2)
That's the fastest wa
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 that tricycle and pulling up to fondle the handlebar streamers.
Exceptions are ... (Score:2)
Now, everyone says "what the hell, I'll just write it and wrap it in a try/thows exception" instead.
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 catcher just generalizes all exceptions away you spend a couple hours wondering why you are getting a socket error when the code you added had nothing to do with sockets.
ugh, I just simply hate having to pick up other people's code. Especially code that has 0
Well... (Score:2)
leg cramps (Score:2)
light stretching
problems be gone!
Re:leg cramps (Score:2)