r/programming • • Jan 30 '14

Google Java Coding Standards

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

19 comments sorted by

View all comments

4

u/kersurk Jan 30 '14 edited Jan 30 '14

Bad: Can't understand why 4.8.4.3 could be useful or nice:

Each switch statement includes a default statement group, even if it contains no code.

Good: I find 6.3 to be a very nice idea to show that static method really changes all of the instances of the object (assuming that the name of variable, which holds a reference to a object, and class name itself are similar).

When a reference to a static class member must be qualified, it is qualified with that class's name, not with a reference or expression of that class's type.

3

u/Alborak Jan 31 '14

The switch default block requirement probably comes testing, it makes it easier to see if a value misses all cases.

1

u/froops Jan 31 '14

For 6.3, I can't imagine why anyone would want to use the alternative of referring to static things with an instance

1

u/Plorkyeran Jan 31 '14

In Java I don't think there's ever a good reason to do so (bad reasons are because it's shorter or due to not realizing it's static). Maybe if the fact that it's static is merely an implementation detail, but I'm not sure how that could ever be the case.