"With more changes being requested by the business and less time allowed to turn around those changes, we've fallen a bit behind on our deadlines," writes Zarar S, "so I requested that we bring on a contractor to help fill in. It was a long shot, but hey, anything not to come in to the office weekend after weekend."

"Amazingly," Zarar continues, "the Powers That Be granted my request and added a 'twenty-year veteran' with 'great Java experience' to my team. One of the first things I asked him to do was write a compareTo() method on our Activity classes and integrate them into our reporting subsystem. After a day or so of hard work, this is what the expert came up with."

public int compareTo (Object obj) {
 return (int)((getVarianceAmount() 
   - ((OfferedActivity)obj).getVarianceAmount()));
}

"Since getVarianceAmount() returned a float, I pointed him to the error of his ways. Surely, as an expert, he'd realize that compareTo() would return 0 (i.e. equal) for something like 3.2 and 3.1, and must have made a simple mistake. A couple hours later, he applied the following fix."

public int compareTo (Object obj) {
  return (int)(100.0 * (getVarianceAmount() 
    - ((OfferedActivity)obj).getVarianceAmount()));
}

"It mostly went downhill from there. And yes, I'm still coming in the office, weekend after weekend."