Gotta Leave it on the Track

Interesting thing happened on Friday, and I'm just now getting around to writing about it. One of the new developers here asked me about my opinion on the checked versus unchecked exceptions - otherwise known as the runtime versus typed exceptions. So I talked to this guy for a while about where we use one versus another and why we try to stick to a scheme given that Java itself makes this pretty hard to do. For example, Java has runtime exceptions and typed exceptions in it's code, so when you try to write code like Java's you are stuck trying to make it look like Java, but since there are really no hard and fast rules as to when to use one versus the other, it's a bit tough, and you have of make a lot of judgement calls. Nothing horrible, but something you have to be aware of.

So as we're talking about this, the guy tries to show me that I'm inconsistent in the use of these in the code I've written. I understand exactly what he's trying to do (though he denies it) - he's trying to show me how smart he is in an effort to gain my respect. Missed the boat entirely.

This kind of "See how smart I am?" crud does the exact opposite for me. Sure, you look at the Vector class and there are a lot of exceptions that are unchecked - ArrayIndexOutOfBoundsException is one. In JDBC this would be a checked exception for sure, but here, it's not. Why? Who knows. More importantly, who cares? When you're writing JDBC-based classes and extending them, you have to live in that little sub-universe of Java, and stick to their pseudo-standards. In the case of the Vector, you have to stay in the world of JDK 1.1 and realize that in the beginning they weren't using a lot of checked exceptions, so you have to make you code look a lot more like that - certainly if you're subclassing Vector (which was the case in this instance). Then he asked me to look at his code and what would I do in this specific case.

I looked at the code and said that he should check the input parameters, check all returned values, and single-entry/single-exit all methods. These are the three most basic coding standards that I have and believe in them without question - regardless of the language. He then said that this code didn't need that. A light then went off in my mind and I knew exactly who this guy was. By the way, he was the Rock Star of the previous few day's posts. This guy was a lazy Rock Star coder.

I asked him my one of my favorite questions about self-image and human nature: If you were driving on a road at 2:00 am and came upon a stop light that was red, and could see far in all directions, far enough to see that no one was coming, would you run the red light? His answer was "Yes", as I knew it would be. I pointed out to him that this tells me he believes himself above the "rules" made by others. After all, the stop light is just supposed to keep us safe, or is it the law to obey them? Yes, it's a law, but many people think it's really optional, and so feel that it's their life, and they can decide what's important and what's not, and they decide that this light isn't worth stopping for.

So we look at his code. We talk more and it comes out that he's built server-side code that has all these checks in it, but he hasn't put them in this particular code because he thinks it's not worth it. I ask him: "Why isn't this section of ten lines of code worth your very best efforts?" He has no answer, and wants to change the subject - which means he knows that I'm right, and that well documented, error-checking code is really better than code that's totally optimistic and undocumented. But he was trying to show me how smart he was, and this is really spoiling his plans. Sad day.

This goes into every aspect of a person's life - you either run it out to first base, or you pull up if you think you might not make it. You either go all out every time, or you sluff it off. You play at your level, or you sandbag. It's personal honesty and integrity. As Yoda said: Do or do not. There is no try. and he wasn't talking about giving your best effort and failing, he was talking about giving it everything you have all the time, believing that this is the last time you'll ever get a chance to do this, or you hold back, take it easy, realize this isn't a playoff game, etc.

I have no interest in living my life the latter of those two. I have to give it everything I have every minute of every day, or I'm just not going to feel like I can look myself in the mirror in the morning. And when I give it everything I have, I can look myself in the mirror - win or loose, and know that the only thing I can do is practice, because there's nothing I could have done to change the outcome - there's only what I can do to change it the next time.