John was maintaining a client management system written a few years before his time and noticed that the original coder had a strange belief about magic numbers. He believe that any number less than three was not "magic" and, therefore, perfectly acceptable to hard code. But numbers three and above ... hard-coding those was just a flat-out bad practice. Everyone knows that you should use strings for those ...
caseMgr.setAssetId(result.getResults().elementAt(0).toString());
caseMgr.setTypName(result.getResults().elementAt(1).toString());
caseMgr.setValCode(result.getResults().elementAt(2).toString());
caseMgr.setValDesc(result.getResults().elementAt(Integer.parseInt("3")).toString());
// another example ...
public void setPhoneNumber(String aPhoneNumber)
{
if (aPhoneNumber != null)
{
setAreaCode(aPhoneNumber.substring(0, Integer.parseInt("3")));
this.PhoneNumber = aPhoneNumber.substring(Integer.parseInt ("3"), Integer.parseInt ("10"));
}
}