Home > WTF > Yet another WTF moment

Yet another WTF moment

boolean found = false;
for (int pr=0; pr<promotions.length; pr++) {
    Promotion promotion = promotions[pr];
    if (promotion!=null && promotion.getName().equals(""+availablePromotions[pr][a1].getPackageId())) {
        externalPromotions[pr] = externalPromotions[pr];    // WTF!!! Assigning a value to itself.
        found = true;  // Not sure what this is
        break;
    }
}
found = false;  // As soon as the loop exits this goes back to false again. WTF!!!

The above is an actual snippet of code from a production system (the comments are mine). And yes, I am serious.

Categories: WTF
  1. 9 June 2014 at 3:02 pm

    Reblogged this on Dinesh Ram Kali..

  2. 17 June 2014 at 3:43 pm

    I am pretty sure he learned the whole “found” methodology in a course featuring a language without a break statement.It can be used to emulate it with a few modifications.I am from Greece, and we learned such a language in the final year of high school.So yea, this is the work of a very, very confused mind.

  3. 4 July 2014 at 1:40 pm

    ROFL!

  4. 15 November 2014 at 7:36 am

    Brilliant. I love things like this. Presumably at some point it modified something! Wouldn’t have happened with testing 🙂

  5. 20 March 2015 at 6:00 am

    I think that the code initially did something and then was modified hastily a couple of times.

    Check out one of my WTF moments with Java http://www.coding-dude.com/wp/java/java-integer-equals-integer-wtf-moment-java/

  1. No trackbacks yet.

Leave a comment