J. K.'s boss loves the term "generic." Developing a feature that prompts if one specific field is left blank, that will only be used on that page? Make it generic enough to work on any page. Working on an application that will only ever be used by the local government in Podunk, MA? Make it generic enough to be able to easily change every line of text into Swahili, just in case. He didn't know the ins and outs of what was involved to make this possible, he just wanted his team to wave their collective genericification wand over the application's code.

This is precisely why he was so upset when an email form that was supposed to be generic wasn't working all of the time. It had been built to convert any HTML form with a properly named From, To, and Subject line into an email. And it worked for the most part, until they tried to apply it to a new form with more fields than others that used the control.

Looking in to the code, it didn't take J. K. long to figure out why it wasn't working on the new form.

String memo = "";
for (int i = 0; i < usedField.length; i++) {
   if("From".equals(usedField[i].getText())){
      request.getSession().setAttribute("From", usedField[i].getValue());
   }
   if("Sendto".equals(usedField[i].getText())){
      request.getSession().setAttribute("Sendto", usedField[i].getValue());
   }
   if("Subject".equals(usedField[i].getText())){
      request.getSession().setAttribute("Subject", usedField[i].getValue());
   }
   if("Body0".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body1".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body2".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body3".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body4".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body5".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body6".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body7".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body8".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body9".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   if("Body10".equals(usedField[i].getText())){
      memo += usedField[i].getValue();
   }
   // Dozens of "if"s removed for sanity
}

...And it didn't take long after he found this code for him to submit it to The Daily WTF, either.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!