Java Coding Style


In general we should try to follow common Java style conventions as used (e.g.) in the JDK classes:
  • Naming:
    • Class and interface names should begin with a capital letter and use inner caps, e.g. "MouseListener", not "mouseListener".
    • Static fields should be all caps
    • All other variables should begin with a lower case letter
  • Spacing:
    • Use multiples of 4 spaces for indenting. Use tabs at 8 spaces to simplify this.
    • Limit lines to 80 characters
  • Comments
    • Always provide a class header comment. Include the string $Id: Exp $ to cause CVS to insert version information.
    • Class and method header comments should use /** ... */ comment delimiters.
    • Inline comments should use the // .... comment delimiter. DO NOT use the /* ... */ delimiters for inline comments.
    • Inline comments (and header comments, where appropriate) should convey rationale for non-obvious segments: why is the code there?
    • ALWAYS provide a change description when prompted by cvs on commiting a change.


/public/chci/howto/dev/style.html Login | Web Editor | Full Editor
Last modified 9/7/03 1:22 PM by isenhour (history)
Site contents