Reputation: 11808
If you have a class member that is static
and public
. Would you write static public
or public static
? I know they are the same. But is there some recommendation / best practice for writing this?
Upvotes: 48
Views: 28059
Reputation: 39059
I personally would go with public static because it's more important that it's public than that it's static.
And check this: http://checkstyle.sourceforge.net/config_modifier.html
As well as this: http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html (These two links are for Java, but the concept is the same)
Short version: "public static" is recommended and is far more common.
Upvotes: 4
Reputation: 14449
When nothing else matters, go with consistency. In this case the rest of the world uses public static
, so I'd go with that too just to avoid unnecessary surprise in those reading your code.
Upvotes: 15
Reputation: 49522
see this question
If you download the Microsoft StyleCop Visual Studio addin, it can validate your source code against the rules Microsoft use. It likes the access modifier to come first.
Upvotes: 24
Reputation: 25780
"public static" is far more common, so you might want to go with that just to increase readability for programmers who never stumbled upon "static public".
Upvotes: 42