1 comment

[ 3.0 ms ] story [ 19.4 ms ] thread
That's an extremely bad example - why would cat ever fall through to dog? At least come up with a situation where fall through makes sense.

Generally, IMO, it's a much better idea to use meaningful constants and method names.

So the code becomes:

    switch(action) {
      case CHECK_AND_FOO:
        check();
  
      case FOO:
        foo();
        break;
  
      default:
        llama();
    }

Now, Joe would not only know not to add in a break, but also why - all without adding a single comment.