At Initrode, their main business is large-scale data warehousing. Their products are used by the biggest companies in the world, and to keep up with demand, naturally, they have hundreds of rock star developers churning out incredible solutions.

They also have Commander Joe.

"The Commander" manages multiple projects, and despite having no Java experience, he loves to "help out" the team by diving into the Java projects.

For example, here was one of Commander Joe's latest check-ins:

// JIRA-381 Joe
try {
  checkForwardEmail();
  } catch (Exception e) {
  String msg = e.getMessage();
  if (msg != null) {
    msg = msg + "";
  }
}

Our anonymous submitter happened to notice this particular check-in and, in an effort to be helpful, relayed a few tips:

  • If you need to add a comment, it should be descriptive and relevant to the code
  • The ticket number and your name are tracked by version control
  • If possible, try to avoid catching the generic "Exception" class
  • When you catch an exception, do something meaningful

The Commander took this advice to heart, realized the error of his ways, and dutifully corrected his errors ahead of his next check-in:

// <JIRA-381 owner="CmdrJoe" comment="check forward email">
try {
  checkForwardEmail();
  } catch (Throwable t) {
  String msg = t.getMessage();
  if (msg != null) {
    msg = msg + "";
    System.out.println(msg);
  }
}
// </JIRA-381>