I just had to node this, as this was the worst piece of source code I had ever seen in my life. It took me a while to figure it out:

while (1)
{
  if (someRoutine1())
    break;

  if (someRoutine2())
    break;

  if (someRoutine3())
    break;

  if (someRoutine4())
    break;

  break;

}

At least it was indented, but it just seemed like a cheesy way to avoid writing a goto statement or a nice nested if statement. Or a rethought design. (This is in the days of just plain C). Of course, the worst comment I ever read was "Think twice before you touch this routine." I ended up simplifying the 20 line routine into 3 lines. (I guess I thought twice.) Now that I am working in Java, along with the rest of my company which is also new at Java, I'm sure that I'll find new "worst piece of code I've ever seen" to add.
I speak prophetically. I have an addition to that evil code from hell: (and yes, it was necessary... the "waitFor()" method did not WORK under AIX... so, we had to impose a timeout on how long the process would execute for)
    long lDt = (1000 * 60 * 3) + System.currentTimeMillis();
    // If the process hasn't REALLY exited, then we'll generate an
    // exception.  If it has exited, then we will not.
    while (true)
    {
      try
      {
        shellReturn = myProcess.exitValue();

        // HEY!  I really DID get an exit value... I can break out of this loop!
        break;

      }
      catch (IllegalThreadStateException e)
      {
        // you know what, if we got here, the program hasn't exited yet.
        // So, have we been waiting for too long yet?
        if (System.currentTimeMillis() > lDt)
        {
          // Yeh, we have.  Let's give up on this deadbeat process.
          _logLine("Process timed out!");
          break;
        }
      }
    }

Log in or registerto write something here or to contact authors.