aspose file tools*
The moose likes Beginning Java and the fly likes Java coding convensions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java coding convensions" Watch "Java coding convensions" New topic
Author

Java coding convensions

Ravi Danum
Ranch Hand

Joined: Jan 13, 2009
Posts: 104
Hello,

What is a good source for: 1) Java naming convenTions, and 2) Java coding conventions. So far, I have seen one dated 1999 from Sun. Is there anything newer and something which contains coding conventions such as Exception handling?

Thanks.

Ravi
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Best Practices for Exception Handling
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
I know of no more recent coding conventions, but there is a style guide on JavaRanch here. Beware: It is much more restrictive than the Sun guide. Until somebody (teacher or employer) imposes a style guide on you, you can use your own. But make sure to be consistent.

Campbell's rule about Exceptions: the number of different opinions is equal to the number of different people asked You will find a different opinion in the Java Tutorials, and maybe in the links at the bottom of the article quoted earlier.
Ravi Danum
Ranch Hand

Joined: Jan 13, 2009
Posts: 104
Thank you for your help.

Ravi
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
You're welcome
Tage Nielsen
Greenhorn

Joined: Jan 31, 2009
Posts: 1
I've done some google searches, and found about 4 or 5 style guides, all of them have similar rules, though the placement of the opening bracket { after classes, methods, loops, etc appear contentions.

Since I am new to Java and it appears that this 'ranch' is a great resource I'm going to use the JavaRanch's style guide for self-study, and for posting here.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
Welcome to JavaRanch Tage Nielsen.

Many of use prefer to put the opening brace (better term than bracket for {) { on its own line because the { and } are then aligned vertically like thisThat makes them easier to read. I heard that the style where the opening brace is not on its own line (on Wikipedia they called that K&R indentation after Kernighan and Ritchie [not me]) was devised to save space when printing on paper. People who are used to K&R seem to find no difficulty reading their code.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java coding convensions