Many months ago, I did a TechEd talk entitled "What's wrong with this code?". I've decided to re-target those snippets into blog posts. If you were at the talk, this may be boring, though I'll try to add a little anecdotal information in my answers.

Here's the plan:

  1. I post the snippet
  2. You comment on what's wrong with it
  3. I post my answer, and any comments that I like
  4. Repeat until I run out of snippetts.

Here's the snippet:

switch (s) {
   case "a":
      try {
         HitA();
      }
      catch (Exception e) {
         throw e;
      }
      break;
   case "b":
      try {
         HitB();
      }
      catch (Exception e) {
         throw e;
      }
      break;
}
 
What's wrong with this code?