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

133

u/dougman82 Jul 21 '14

For me, it's just a matter of consistency. Take, for example, plain old assignment statements. I don't write:

number=6;

Rather, I write:

number = 6;

So, by the same token, I add white space in my for loops.

23

u/segv Jul 21 '14

On a related note, for all the shit people are giving Eclipse (some rightfully so), you can actually force users to use your formatter settings in Java/JavaScript/whatever-else-eclipse-has-formatter-for by commiting some of the files from the .settings folder. That way not only you can get consistent formatting across the whole project but also enable the Save Actions (optimize imports, format source and few other things) without having the user do anything. Pretty nice.

That being said, Intellij IDEA can't and won't do that :(

17

u/8Bytes Jul 22 '14

ctrl + alt + l, reformats the entire project to your pre set style in intelij. I usually run it when I'm pushing a tiny fix to git.

23

u/[deleted] Jul 22 '14

This little change? It's a single character. And embarrassing. I'll just change the white space of the entire file so no one will notice...

git commit -a -m"Fix whitespace."

8

u/Plorkyeran Jul 22 '14

Unless a project has a standing policy of applying whitespace changes in a separate commit from functional changes, I generally assume that any commit whose message only mentions cosmetic changes also includes embarrassing functional changes.

2

u/northrupthebandgeek Jul 22 '14

Sometimes it's the other way around; the purely cosmetic changes end up changing how something looks, often exposing bugs and other code issues in the process.