26 July 2007 - java_dev (original) (raw)
Why don't people write sensible exception handling? Why do some people hate checked exceptions?
Looking at other people's code, I'm often appalled at the sloppiness. This starts with small things: they don't bother with laying code out readably. I have my own prejudices about good layout, but I don't mind if other people do it differently, as long as they DO do it. How can I even read the code if the indentation is all over the place?
Why don't they try harder? I think the reason may be that they can't. All their effort is absorbed by getting the code to compile and run. There's not spare brain cycles for anything besides the minimum to get it working.
Now if this is true, it's obvious why exceptions are a problem. There are no spare brain cycles for thinking of what happens off the happy path. "My database query returned exactly one row when I tried it, so that's the only possibility I have to deal with." And so it probably is, all the time this developer is working on this code. They have to deal with that annoying SQLException because the compiler forces them to, but their response is to do the minimum to make the code compile:
try{ // some database stuff }catch(SQLException e){ }
So I suggest that people don't do sensible exception handling because they assume things will always go right, and therefore checked exceptions are an annoyance.