As a consultant, one of Maarten De Cock's responsibilities is to analyze his client's code, identify where the developers could use improvement, and train them on how to write higher-quality code. Most of the developers that Maarten works with get it: they take in the techniques, apply them, and go back to improve the existing code. Others, not so much.

Following is the refactoring done by a group of developers Maarten that worked with. They seem to have mastered method extraction and code reuse, they really struggle with understanding where to apply it. The eight places where the authorization logic exists probably would have been a better place to start ...

/**
 * Method is01.
 * @param authCode
 * @return boolean
 */
private boolean is01(String authCode)
{
  if ("01".equals(authCode)) return true;
  else return false;
}

/**
 * Method is02.
 * @param authCode
 * @return boolean
 */
private boolean is02(String authCode)
{
  if ("02".equals(authCode)) return true;
  else return false;
}

/* ... snip ... */

/**
 * Method is004or005.
 * @param prodCode
 * @return boolean
 */
private boolean is004or005(String prodCode)
{
  if ("004".equals(prodCode)) return true;
  else if ("005".equals(prodCode)) return true;
  else return false;
}


/**
 * Method is03or09or10.
 * @param prodCode
 * @return boolean
 */
private boolean is03or09or10(String prodCode)
{
  if ("03".equals(prodCode)) return true;
  else if ("09".equals(prodCode)) return true;
  else if ("10".equals(prodCode)) return true;
  else return false;
}