You are perfectly right that the brace-at-end-of-line philosophy is incompatible with conditions spanning multiple lines. However, I believe the problem here is not the philosophy, but rather the long condition!
Conditions should either be very short, or be extracted to a method so that the if
statement reads like well written prose. That’s why I don’t need a (nearly) blank line because my conditions (and code in general) never wrap, and indentation always clearly delimit a block. Continuation indents are almost inexistent in the code style I try to follow.
Well again, if the return type spans multiple lines, then maybe that is not readable enough to start with. We should either create a typealias
or new type to solve this first problem, before putting the non-readability blame on wrapping styles.
Now this part makes sense, although I believe that the body shouldn’t be long enough to need a “frame”.
To summarize, my coding style is to extract many code blocks as methods so that the code really reads well and all methods are short. In this style, there are many methods and blocks, and having a blank line is:
- unnecessary, because blocks are short enough not to need a frame
- harmful, because it means a lot more whitespace is added (compared to a style which prefers long conditions and blocks) and thus less lines of code are displayed on the screen, making it harder to browse
What’s your opinion about this?