• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java coding convensions

 
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Best Practices for Exception Handling
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 165
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your help.

Ravi
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic