Boolean statements are overcomplicated by reversing too many booleans.  For example, take a look at some original code:

public synchronized boolean isRunning()  
{
    if (startThread == null || startThread.isAlive() == false
    {
        return false;
    }
    else  
    {
        return true;
    }
}

When the polarity of the boolean checks are reversed, the statement is more readable:

public synchronized boolean isRunning()  
{
    if (startThread != null && startThread.isAlive())  
    {
        return true;
    }
    else  
    {
        return false;
    }
}

Arguably the if/else condition could be discarded completely, but less readable.

public synchronized boolean isRunning()  
{
    return (startThread != null) && startThread.isAlive();
}
blog comments powered by Disqus