r/java • • Jan 29 '14

Google Java Coding Standards

http://google-styleguide.googlecode.com/svn/trunk/javaguide.html
156 Upvotes

103 comments sorted by

View all comments

36

u/[deleted] Jan 29 '14

4.1.1 Braces are used where optional Braces are used with if, else, for, do and while statements, even when the body is empty or contains only a single statement.

I hate when people omit curly braces for some insane reason. At least Google has my back.

9

u/clutchest_nugget Jan 29 '14 edited Jan 29 '14

if(done) return 1;

Can someone please explain to me what is wrong with this? Not questioning that it's bad style, genuinely curious as to what makes it bad style.

Edit: thanks for the responses.

0

u/[deleted] Jan 29 '14

[deleted]

-18

u/[deleted] Jan 29 '14

I've been programming for 7 years and have literally never made that mistake.

4

u/geodebug Jan 30 '14

Chip meet shoulder

-8

u/[deleted] Jan 30 '14

1990, meet 2014

4

u/geodebug Jan 30 '14

Java's syntax hasn't changed that much since the 1990's so why would the best practices change just because a few years have passed?

Besides, most modern languages have a similar best practice when it comes to braces.

Doesn't matter, code how you want on your projects. If you coded for mine you'd be auto-formatted to the standard anyway.

-5

u/[deleted] Jan 30 '14 edited Jan 30 '14

Oh yeah, you mean like c#? It takes standards decades to change, it takes technology seconds (ie LCD displays.)

6

u/geodebug Jan 30 '14

You've lost me. I think you're just saying random things.

-1

u/[deleted] Jan 30 '14

Then you couldn't have understood the argument I was making from the start of this discussion at all...

→ More replies (0)