Be Safe, Kids – Say NO to Unhandled Exceptions

Written by Emma on September 26th, 2007

I managed to lighten my mood somewhat, so I thought I’d make a post of it. So what was this miracle, you ask? Why, programming, of course.

I was assigned a ‘lab’ yesterday that’s due in… two weeks. For those of you who don’t know, I’m in a brain-numbingly easy intro to programming class for a reason that’s too long of a story for me to bother telling you now.

So I decided to code the program tonight, and did. Met all the requirements and such. It’s a very simple Java applet that lets you divide numbers if you put them in boxes. (And another even stupider function.) Of course, if you try and parse a string to an int (or double) and it’s not all numbers, it throws an exception. Remember those? Of course, it doesn’t actually do much in the visible part of the program, so we were supposed to let those go. But I didn’t like all the angry red lines in NetBeans (and I also don’t like the idea of people trying to divide words in my ‘Number Divider’ without a scolding) so I handled that exception. Somehow, that gave me very much joy.

You can go marvel over the stupid simplicity and (required) eye-fucking colors of my little applet here:

On a side-note, I realised the other day that my favorite Java and/or C++ segment of code would have to be else if. I think this is because it seems so reassuring. ‘Oh, that didn’t work out? Don’t worry! We have a back-up plan! Everything’s going to be fine!’ I like the idea of there being another option after something has failed.

You might think this relates specifically to now, but it doesn’t. I’ve always felt a little happiness at ‘else if‘s, I just never really realised why before.

Long live, my little blue friend.

  • Share/Save/Bookmark

Leave a Comment