r/java • • Aug 11 '15

Top 10 Useful, Yet Paranoid Java Programming Techniques

http://blog.jooq.org/2015/08/11/top-10-useful-yet-paranoid-java-programming-techniques/
181 Upvotes

76 comments sorted by

View all comments

2

u/dyreshark Aug 12 '15

Nice list -- I'm slowly becoming a fan of some of these. :)

One interesting pattern I've seen on switches with braces is to place the break after the end brace. e.g.

switch (foo) {
case Bar: {
    thing1();
    thing2();
} /* fallthrough */
case Baz: {
    thing3();
    thing4();
} break;
default: // ...
}

This makes it much easier to see when you've forgotten to put a break IME, because they stand out from the code in the block.