Mac didn't know anything about how the JavaScript on the search page worked, and he wasn't that great at CSS styling, but that didn't matter. He had his orders. As part of the latest round of enhancements, the front-end developer had added another search parameter which would be passed via the regular search URL, and the back end needed to be adjusted to accomodate. (You know... instead of '' it now was ''.)

No problem. Mac made his tweak in the code and ran a quick test...which failed instantly in a spectacular way. "WTF? It's a parameter. Must be already used..." he thought, but nope.

Digging deeper, Mac came upon the following:

public enum eQueryParametersCount
  New = 2,
  Filtering = 3,
  Navigation = 6,
  SwitchView = 7

Odd. And then peppered throughout...

int iCount = Request.QueryString.Count;
if (iCount != (int)eQueryParametersCount.New
      && iCount != (int)eQueryParametersCount.Navigation
      && iCount != (int)eQueryParametersCount.Filtering
      && iCount != (int)eQueryParametersCount.SwitchView
  logger.Log("QueryString error: invalid querystring");


else if ((Request.QueryString.Count == (int)eQueryParametersCount.Filtering) && (!SetConfirmationMessage()))
       if (!GetOverallQuality())
         logger.Log("QueryString error: r not found or invalid value");

In short, the previous coders figured that it was much better to 'count' the number of parameters to determine what the user wanted instead of actually reading them. It also means you can never have 3 params because that is taken by a different enum.

As Mac set about tearing things apart he found himself considering how tough it would really be to pick up some web design skills.


Photo credit: Laineys Repertoire / Foter / CC BY

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