Now I don't claim to be an excellent coder, but I've seen some really stupid shit in my several years on my current job.
Just now I've come across quite a doozy:
public Connection getConnection(String username, String password) throws SQLException
(
Read more... )
Comments 4
Is the problem that the SQL connection is public? That seems a no-no to me.
Or is the problem in the exception handling, which is more complicated than I can figure out to really go, "WTF?" over, but recognize as at the very least abnormal.
Reply
Typically, you throw exceptions in java when an error case happens, which is why one normally wraps some code in a try catch block in order to trap exceptions and handle them in whatever way that would be appropriate.
The big problem here is that he has a try catch block, but right away he just throws an exception with no other preceding code.
Throwing an exception like that typically means that you are intending for that function to never be called normally. This happens sometimes when you are either extending a class or implementing an interface that has methods that you don't want to be called or don't intend to ever use. But you'd want to just do something like this:
public void dontEverCallMe() {
throw new UnsupportedOperationException("you stupid monkey!");
}
But as you can see, he actually does implement the method after the try/catch, which is puzzling. Essentially, try/catch block he has there does nothing but output stuff to ( ... )
Reply
Reply
This. Seems likely that it's just some hacky debugging code someone threw in and forgot to take out when they were done with it.
Reply
Leave a comment