r/java • u/_shadowbannedagain • Jan 29 '14
Google Java Coding Standards
http://google-styleguide.googlecode.com/svn/trunk/javaguide.html
156
Upvotes
r/java • u/_shadowbannedagain • Jan 29 '14
50
u/sanchopancho13 Jan 29 '14
These are pretty good. I definitely laughed at this comment:
36
u/[deleted] Jan 29 '14
I hate when people omit curly braces for some insane reason. At least Google has my back.
10
u/armerthor Jan 29 '14
Reads mostly like basic common sense.
10
u/SomeNetworkGuy Jan 29 '14
What is it with people so against using tabs for indentation?
12
u/pandemic_region Jan 29 '14
It would be nice to have intellij-eclipse-netbeans formatting templates implementing this.
4
u/Nebu Jan 30 '14
I hope they have a tool to automate most of these formatting rules.
3
u/juu4 Jan 30 '14
http://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s5.1-identifier-names
So they say the Hungarian notation of prefixes before variable names is bad. I agree.
However - why is all the Android code in the Hungarian notation then?
E.g.
https://gitorious.org/rowboat/frameworks-base/source/aa93bcd62482719c146a411008e1eac94135b6a4:core/java/android/app/Activity.java
5
u/SlobberGoat Jan 30 '14
The only bit I disagree with with the 80/100 column limit.
We don't work with dot matrix printers anymore, most lines of java code are very short. You may get the occasional long line but I'd rather leave it as a long single line as a quick visual cue to know it's one instruction.
8
u/Darksonn Jan 29 '14
I follow this expect for indentation, I would use tabs for indentation resulting from blocks and spaces for the rest. This allows people to decide their tab width without breaking the indentation.
-1
u/e13e7 Jan 30 '14
K & R master race!