logo       

OT: Bad examples everywhere (Was: distinguishing between failures and erro: msg#00134

java.junit.user

Subject: OT: Bad examples everywhere (Was: distinguishing between failures and errors)

From: neil_swingler
>o Do nothing
>o Print/log message (but not the stacktrace)
>o Wrap the exception but lose the cause exception and it's stacktrace
>o catch Exception (also catches all those RuntimeExceptions they had
forgotten about

..and then you end up being the one trying to debug this with absolutely no
information since they've thrown the root cause and the stack trace. Arghhh.

I'll add one to your list :
o Print/log message (but with neither the stacktrace & the exception
classname : only the getMessage())

I think this comes from the fact that most sample code (book examples,
tutorial, etc..) that are read by people learning java include code like
this :

try {
//something
} catch{Exception e) {
System.out.println("something bad happened + e.getMessage();
}

Then all you get is :
"something bad happened 4"

People are learning from examples and there aren't that many simple but good
& completes examples out there.

Every JDBC example uses string concatenation to build the SQL (instead of
prepared statements) and then people wonder why the industry has a security
problem with SQL injection!

I just felt like saying it all! :)

mathieu



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

News | FAQ | advertise