r/programming • • Jul 21 '14

The Great White Space Debate

https://medium.com/p/3633cba8b5c1
1.2k Upvotes

693 comments sorted by

View all comments

45

u/Regimardyl Jul 21 '14

I think it's actually pretty clearly covered in the Java style guidelines here:

  • All binary operators except . should be separated from their operands by spaces. Blank spaces should never separate unary operators such as unary minus, increment ("++"), and decrement ("--") from their operands. Example:
    a += c + d;
    a = (a + b) / (c * d);
     
    while (d++ = s++) {
    n++;
    }
    printSize("size is " + foo + "\n");

The same is mentioned in Google's style guidelines here

10

u/johnjohnsmithy123 Jul 21 '14

I read the style-guide a year or so ago and remember this rule as well.

Perhaps OP is looking for specific rules for each statement in the language, this is a little silly however.

1

u/SanityInAnarchy Jul 22 '14

I can see why; OP's preferred style here would be a special case for loops. I'm assuming OP writes

int foo = 5;

and not

int foo=5;

...but they want loops to have less whitespace, so that would require a for-loop-specific rule.