Working on the first try? Try again!

Tip: Be wary of something working on the first try.

If something works on the first try, it’s guaranteed to be screwed up in some way.

A common one for me, as it’s easy to forget, is enabling Java’s assertions. They’re disabled by default and if you use an IDE’s fancy doo-dads to automatically run your JUnit tests then it wont have the assertions enabled (you typically have to manually enable them). All shows green and you move on. At some point later you hit an NPE (NullPointerException — the bane of a Java programmer’s existance) and see that there is an assertion in place. Then you realize that you never enabled assertions. A forhead smack occurs and you spend a day debugging what you should have fixed in the first place (when it was fresh in your mind).

Advertisements

One comment


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s