Don’t touch my braces!
Friday, February 24th, 2006No, it’s not that my pants will fall down if you do, but my Java code might get a bit less intelligible.
Ed Burnette blogs on a nasty little “feature” of Eclipse. First, a little background
Java, C, and C++ share a little syntactic quirk that has bitten all developers on the rear from time to time. Take a look at this code:
if (condition)
doSomething();
doSomethingElse();The “doSomethingElse();” code will always be executed regardless of the value of the condition because only the “doSomething();” statement is considered part of the “if”.
This has bitten me on more than one occasion on source code that has been checked into our repository and edited by multiple people, causing the indentation to get screwed up (eg tabs and spaces). Especially when you’re scanning code you’re not familiar with, indentation is a key indication of code blocks and nesting.