Everyone at Mark's company knew about the Resource Allocation system. To say the least, it was a mess of a Java servlets held together with batch files, spreadsheets, and chewing gum, all developed by programmers who have long since been promoted to Lead Architect and Management roles. A slight change of winds was all that was needed to start a chain reactions of bugs: a while back, an edit to the configuration file to change the notification email address caused the system to bring down the email servers with a loop that became infinite when the config-file value didn't match the hard-coded value.

When word came down that the business would switch to ISO-3166 country codes throughout the enterprise, Mark knew this would have a devastating impact on the RA system. He bravely updated the COUNTRY_CODES table and prepared himself to battle a swarm of bugs. After it all was over, he was kind enough to share one of the more memorable finds from the DatabaseCache class ...

public String getCountry(String countryCode)
{
  StringBuffer countryString = new StringBuffer(5000);
  countryString.append("<OPTION value=\"\">Please select country");
  if(countryCode.equals("US"))
    countryString.append("<OPTION value=US selected>United States");
  else
    countryString.append("<OPTION value=US>United States");
  if(countryCode.equals("AF"))
    countryString.append("<OPTION value=AF selected>Afghanistan");
  else
    countryString.append("<OPTION value=AF >Afghanistan");
  if(countryCode.equals("AL"))
    countryString.append("<OPTION value=AL selected>Albania");
  else
    countryString.append("<OPTION value=AL>Albania");
  if(countryCode.equals("AG"))
    countryString.append("<OPTION value=AG selected>Algeria");
  else
    countryString.append("<OPTION value=AG >Algeria");
  if(countryCode.equals("AN"))
    countryString.append("<OPTION value=AN selected>Andorra");
  else
    countryString.append("<OPTION value=AN>Andorra");
  if(countryCode.equals("AO"))
    countryString.append("<OPTION value=AO selected>Angola");
  else
    countryString.append("<OPTION value=AO>Angola");
  if(countryCode.equals("AV"))
    countryString.append("<OPTION value=AV selected>Anguilla");
  else
    countryString.append("<OPTION value=AV>Anguilla");
  if(countryCode.equals("AC"))
    countryString.append("<OPTION value=AC selected>Antigua and Barbuda");
  else
    countryString.append("<OPTION value=AC>Antigua and Barbuda");
  if(countryCode.equals("AR"))
    countryString.append("<OPTION value=AR selected>Argentina");
  else
    countryString.append("<OPTION value=AR >Argentina");
  if(countryCode.equals("AM"))
    countryString.append("<OPTION value=AM selected>Armenia");
  else
    countryString.append("<OPTION value=AM >Armenia");
  if(countryCode.equals("AA"))
    countryString.append("<OPTION value=AA selected>Aruba");
  else
    countryString.append("<OPTION value=AA >Aruba");
  if(countryCode.equals("AT"))
    countryString.append("<OPTION value=AT selected>Ashmore and Cartier Islands");
  else
    countryString.append("<OPTION value=AT >Ashmore and Cartier Islands");
  if(countryCode.equals("AS"))
    countryString.append("<OPTION value=AS selected>Australia");
  else
    countryString.append("<OPTION value=AS >Australia");
  if(countryCode.equals("AU"))
    countryString.append("<OPTION value=AU selected>Austria");
  else
    countryString.append("<OPTION value=AU >Austria");
  if(countryCode.equals("AJ"))
    countryString.append("<OPTION value=AJ selected>Azerbaijan");
  else
    countryString.append("<OPTION value=AJ >Azerbaijan");
  if(countryCode.equals("BF"))
    countryString.append("<OPTION value=BF selected>Bahamas");
  else
    countryString.append("<OPTION value=BF >Bahamas");
  if(countryCode.equals("BA"))
    countryString.append("<OPTION value=BA selected>Bahrain");
  else
    countryString.append("<OPTION value=BA >Bahrain");
  if(countryCode.equals("BG"))
    countryString.append("<OPTION value=BG selected>Bangladesh");
  else
    countryString.append("<OPTION value=BG >Bangladesh");
  if(countryCode.equals("BB"))
    countryString.append("<OPTION value=BB selected>Barbados");
  else
    countryString.append("<OPTION value=BB >Barbados");
  if(countryCode.equals("BS"))
    countryString.append("<OPTION value=BS selected>Bassas Da India");
  else
    countryString.append("<OPTION value=BS >Bassas Da India");
  if(countryCode.equals("BO"))
    countryString.append("<OPTION value=BO selected>Belarus");
  else
    countryString.append("<OPTION value=BO >Belarus");
  if(countryCode.equals("BE"))
    countryString.append("<OPTION value=BE selected>Belgium");
  else
    countryString.append("<OPTION value=BO >Belarus");
  if(countryCode.equals("BH"))
    countryString.append("<OPTION value=BH selected>Belize");
  else
    countryString.append("<OPTION value=BH >Belize");
  if(countryCode.equals("BN"))
    countryString.append("<OPTION value=BN selected>Benin");
  else
    countryString.append("<OPTION value=BN >Benin");
  if(countryCode.equals("BD"))
    countryString.append("<OPTION value=BD selected>Bermuda");
  else
    countryString.append("<OPTION value=BD >Bermuda");
  if(countryCode.equals("BT"))
    countryString.append("<OPTION value=BT selected>Bhutan");
  else
    countryString.append("<OPTION value=BT >Bhutan");
  if(countryCode.equals("BL"))
    countryString.append("<OPTION value=BL selected>Bolivia");
  else
    countryString.append("<OPTION value=BL >Bolivia");
  if(countryCode.equals("BK"))
    countryString.append("<OPTION value=BK selected>Bosnia and Herzegovina");
  else
    countryString.append("<OPTION value=BK >Bosnia and Herzegovina");
  if(countryCode.equals("BV"))
    countryString.append("<OPTION value=BV selected>Bouvet Island");
  else
    countryString.append("<OPTION value=BV >Bouvet Island");
  if(countryCode.equals("BR"))
    countryString.append("<OPTION value=BR selected>Brazil");
  else
    countryString.append("<OPTION value=BR >Brazil");

... sniped a whole bunch of countries ...

  if(countryCode.equals("TX"))
    countryString.append("<OPTION value=TX selected>Turkmenistan");
  else
    countryString.append("<OPTION value=TX >Turkmenistan");
  if(countryCode.equals("TK"))
    countryString.append("<OPTION value=TK selected>Turks and Caicos Islands");
  else
    countryString.append("<OPTION value=TK >Turks and Caicos Islands");
  if(countryCode.equals("TV"))
    countryString.append("<OPTION value=TV selected>Tuvalu");
  else
    countryString.append("<OPTION value=TV >Tuvalu");
  if(countryCode.equals("UG"))
    countryString.append("<OPTION value=UG selected>Uganda");
  else
    countryString.append("<OPTION value=UG >Uganda");
  if(countryCode.equals("UP"))
    countryString.append("<OPTION value=UP selected>Ukraine");
  else
    countryString.append("<OPTION value=UP >Ukraine");
  if(countryCode.equals("AE"))
    countryString.append("<OPTION value=AE selected>United Arab Emirates");
  else
    countryString.append("<OPTION value=AE >United Arab Emirates");
  if(countryCode.equals("UK"))
    countryString.append("<OPTION value=UK selected>United Kingdom");
  else
    countryString.append("<OPTION value=UK >United Kingdom");
  if(countryCode.equals("UY"))
    countryString.append("<OPTION value=UY selected>Uruguay");
  else
    countryString.append("<OPTION value=UY >Uruguay");
  if(countryCode.equals("UZ"))
    countryString.append("<OPTION value=UZ selected>Uzbekistan");
  else
    countryString.append("<OPTION value=UZ >Uzbekistan");
  if(countryCode.equals("NH"))
    countryString.append("<OPTION value=NH selected>Vanuatu");
  else
    countryString.append("<OPTION value=NH >Vanuatu");
  if(countryCode.equals("VT"))
    countryString.append("<OPTION value=VT selected>Vatican City");
  else
    countryString.append("<OPTION value=VT >Vatican City");
  if(countryCode.equals("VE"))
    countryString.append("<OPTION value=VE selected>Venezuela");
  else
    countryString.append("<OPTION value=VE >Venezuela");
  if(countryCode.equals("VM"))
    countryString.append("<OPTION value=VM selected>Vietnam");
  else
    countryString.append("<OPTION value=VM >Vietnam");
  if(countryCode.equals("VQ"))
    countryString.append("<OPTION value=VQ selected>Virgin Islands");
  else
    countryString.append("<OPTION value=VQ >Virgin Islands");
  if(countryCode.equals("WF"))
    countryString.append("<OPTION value=WF selected>Wallis and Futuna");
  else
    countryString.append("<OPTION value=WF >Wallis and Futuna");
  if(countryCode.equals("WE"))
    countryString.append("<OPTION value=WE selected>West Bank");
  else
    countryString.append("<OPTION value=WE >West Bank");
  if(countryCode.equals("WI"))
    countryString.append("<OPTION value=WI selected>Western Sahara");
  else
    countryString.append("<OPTION value=WI >Western Sahara");
  if(countryCode.equals("YM"))
    countryString.append("<OPTION value=YM selected>Yemen");
  else
    countryString.append("<OPTION value=YM >Yemen");
  if(countryCode.equals("ZA"))
    countryString.append("<OPTION value=ZA selected>Zambia");
  else
    countryString.append("<OPTION value=ZA >Zambia");
  if(countryCode.equals("ZI"))
    countryString.append("<OPTION value=ZI selected>Zimbabwe");
  else
    countryString.append("<OPTION value=ZI >Zimbabwe");
  countryString.append("</OPTION>");

  //ED: Yes, contryOptions is a class-level field
  countryOptions = countryString.toString();
  return countryOptions;
}
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!