7. Other style guides Update Jan 30, 2009: Some of the links were broken, they should all work now. There are a number of code style guides for Java available that are interesting to know about, since you may come across code that uses them. Here you can find references to some of the most common style guides. Remember that you shouldn't mix different style guides. If you make changes to code that uses a different style than you normally do yourself, try to adhere to the style guide already in use and do not impose your own style. One style guide that you are quite likely to come across is Sun's Code Conventions for the Java Programming Language. It differs from this style guide in some aspects, like having rules for white space, but is nevertheless worth knowing about. You can find it at http://java.sun.com/docs/codeconv. Netscape's Software Coding Standards Guide for Java is also well worth checking out. It is quite old by now and not easily found on the net, but it still has some good points to make, so for the convenience of the reader it can be found here. In their book The Practice of Programming (Addison-Wesley), Brian W. Kernighan and Rob Pike devote the entire first chapter to style. This chapter (and the whole book) is well worth reading, especially the section on idioms. When looking at code style guides you often find references to a standard written by Doug Lea, well-known authority on Java in general and author of Concurrent Programming in Java (Addison-Wesley). His standard is available at http://g.oswego.edu/dl/html/javaCodingStd.html. This page also has some links to other standards that aren't mentioned here. Some people at Rouge Wave have written The Elements of Java Style (Cambridge University Press), which is both a style guide and a collection programming practices for Java. A recommended read, but perhaps a bit too detailed sometimes. A white paper that forms the basis of that book can be found at http://www.ambysoft.com/essays/javaCodingStandards.html IBM has developed a standard for JavaBeans coding which uses prefixes in very much the same way as this style guide. It used to be available at the redbooks site, but it is no longer there and I haven't been able to locate it elsewhere. Finally, it can be of historical interest to have read Charles Simonyi's Hungarian notation standard, bearing in mind that it was developed for the C programming language and has little practical use for Java. It will give you an idea of how Microsoft was thinking when they designed the Win16 and Win32 APIs. You can find the Hungarian notation in many locations, one is http://msdn.microsoft.com/en-us/library/aa260976.aspx. |
Previous | Contents |