Home > Java, WTF > WTF code!

WTF code!

While I was looking at some legacy code I stumbled upon a few wtf! moments. This is code that surprised me and made me laugh. Not that I haven’t written bad code in my life, but this is hilarious.

setPMPLogHistory(new Integer(applicationId).toString());

In the code above, the variable applicationId is already a String! The developer first creates a new Integer instance from a String and then turns this into a String again!

info.getApplicationTypeID().equalsIgnoreCase("1")

Apart from the obvious refactoring (the “1” should be at the beginning of the comparison in order to avoid a npe) you don’t have upper/lower case digits, so the equalsIgnoreCase is unnecessary.

Advertisements
Categories: Java, WTF
  1. 7 October 2013 at 12:00 pm

    Haha!!! This is a complete WTF 🙂

  1. No trackbacks yet.

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

%d bloggers like this: