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 ...


// 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"));
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!