Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] A matter of style: loops vs. streams and - gasp - braces

Even though it looks like the discussion has concluded, I'd like to throw in my two cents for the loosing side :)
The only difference of braces / no braces approach is ONE SINGLE LINE needed additionally.
That's one way to put it. Another way is that in worst case the line count will increase by 50%! (even more if we considered nested structures, but that may be going too far).
Is this really worth the risk to have broken code?
Therefore the safest solution we found (absolutely fool proof) is simply to use braces, and it works perfectly, with no one complained so far about readability of our code in this area.

Maybe it's lack of experience, but I can't see how this rule can be absolutely fool proof while there's such a high risk of bugs without it. If there's so much complicated merging that it's easy to mess up indentation and not put braces where necessary, it's probably equally easy to mess up by putting a line on the wrong side of a brace.

No one complains about it - but how many are like me, who prefers the shorter version, but never thought of it as a big deal? :)

This is really not worse from readability point of view, and it also off-load your brain that does not need extra cycles to check if the line indent matches control flow or vise versa.

I think it's a matter of taste (so it makes perfect sense for you as a lead developer to enforce this rule). For me it's sometimes more pleasant (and thus less demanding) to read code with less braces. My personal rule is to skip braces only when header and body take one line each. And even then I sometimes add braces to emphasize the code is doing something significant (rather than a simple break or something) or there's a high chance it will expand in the future.


Back to the top