views:

623

answers:

8

What Java Programming Guidelines you are using? I know that the most common is the one provided by Sun (http://java.sun.com/docs/codeconv/) but I would like to know if there are other market standards.

+5  A: 

2 good references:

As @Bill mentions Checkstyle / PMD / Findbugs can be used for automated checking.

toolkit
+2  A: 

I use those that you linked to as a starting point. One pointer that I can give you is to configure a tool like Checkstyle or PMD to help you conform to whatever standard you settle on.

Bill the Lizard
Thanks Bill - I'm going to take a look at this.
Software Monkey
A: 

Im currently tutoring a Java Class and we're using some free Java Videos and we are using the book Head Start Java , which even i as an experienced programmer find fun and interesting. It has a very cool and good perspective.

Since the human brain has only 2 was of remembering things, either by "force", this meaning that you need to repeate untill you understand. Or by reference, meaning that if you see a nice Object and you can assosiate this with a image or something that happend, you will remember.

Head start java uses a lot of good explaining images and is a good Guideline to become a generally good programmer.

Filip Ekberg
I believe the question was on coding conventions, not coding skill.
Spencer K
Then the question should state that more explicitly. Programming guidelines can very much be "how to learn programming". And afaik Head start java covers convetion too.
Filip Ekberg
Good to see new people trying to help out though! Welcome!
Bill K
+2  A: 

I've been programming in Java since it came out and have never worked with a group that found conventions to be necessary. The biggest debates seem to be if you should use this. for member variables and which line to put opening braces on.

I just tend to pick up whatever styles my current project uses and go with it. Getting emotional or instant about it is a complete waste of time.

However, readable code is critical. It's assumed that you will have sufficient whitespace and javadocs on public methods for the most part. It's just that brace alignment doesn't really effect readability as much as some people with Anal Brace Alignment Stress Syndrome would like you to believe.

Bill K
+1  A: 

I've noticed most Java code actually follows the guidelines set by Sun. What's interesting is I bet most people didn't even know there were such guidelines, yet they were already following them.

This is a case of monkey see, monkey do, which is a good thing. This has allowed Java code to be far more readable than other languages which have a lot more history.

Why are you even looking for another guideline?

Its become the de facto standard. Use it.

Pyrolistical
A: 

I use a set of standards I've published here:

http://www.softwaremonkey.org/Article/CodingStandards

and I use the less common banner indentation standard:

http://www.softwaremonkey.org/Article/CodeLayout

Software Monkey
While I don't agree with your code layout rules (but it is a highly subjective topic), I appreciate the last paragraph about having the liberty to choose _our_ coding conventions, as long as they are consistent.
PhiLho
A: 

As well as seconding toolkit's recommendations of Effective Java and Elements of Java Style a new book which I feel communicates the concept of style (and more importantly craftsmanship) very effectively is Robert Martin's "Clean Code: A Handbook of Agile Software Craftsmanship"

This focuses not so much on whether there is a space before each '{' but on what are the real differences between good code and bad code.

http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882

Get it, read it, absorb it and then pass it on to your team.

Stevo
A: 

I use this:

http://satukubik.com/2010/01/06/my-eclipse-code-formatter/

You can get the Eclipse formatter definition from GitHub.

nanda