Wednesday 2 May 2012

Another weird if statement

Found the following code at my work.

if (order.getOrderCode() == null
{
    simpleOrder = true;
}
else 
{
    if (order.getOrderCode().length() == 0) 
    {
        simpleOrder = true;
    }
}

Refactor.

Note: There are plenty of libraries that offer very good single static operations to replace the if condition, but that's not important right now.