Showing posts with label WTF. Show all posts
Showing posts with label WTF. Show all posts

Sunday, 13 August 2017

WTF code! ~ foundjava

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.
1
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!
1
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.
Read More »

Not tested yet! (WTF) ~ foundjava

This is some production code, that fails.
1
2
// Do conjunction////NOT TESTED YET???I dont know what will happen : (
startConjunction(customers, application);
Not sure if the author forgot the comment there or it indeed is not tested. But knowing that the code might not work and not fixing it is really WTF!
Read More »

More WTF! ~ foundjava

1
2
3
4
5
6
7
if (true)
{
    if (externalCreditDeposit == 0)
        creditDeposit = internalCreditDeposit;
    else
        creditDeposit = intWeight * internalCreditDeposit + extWeight * externalCreditDeposit;
}
Just to make sure that it will always be executed!
1
2
3
4
5
6
7
// Variable declaration
        String oldMsisdn = "";
        String newMsisdn = "";
        int rows = 0;
        int cols = 0;
        int tmp = 0;
        int listPtr = 0;
Just to make sure that we know there are variable declarations!
1
2
3
4
5
6
7
8
9
if (request.getParameter("hasBlackberyFromTor")!=null && request.getParameter("hasBlackberyFromTor").equals("1")) {
        
                  
         }else{
         
         
         blackberryExtraPlus  = "-22";
              
         }
Unnecessary empty if statement.
Read More »