JavaGit Style Guide

All JavaGit code must conform to the following Java Style Guide. For items not covered in this document, see Sun's Code Conventions for the Java Programming Language.

An Ecplise formatter definintion file that (nearly) matches this policy can be acquired at: . See below for how to install it.


  • Lines cannot exceed 100 characters
  • NO TABS. Indentation must be 2 spaces except when continuing an expression or declaration from a previous line, in which case 4 spaces should be used.


  • All files must include javadocs, including unit tests
  • Multi-line comments should use /* ... */, while single line comments should use //
  • Do not use trailing comments. To comment a line of code place the comment immediately above the line.


  • Use one declaration per line, and use the standard Java naming conventions.
  • Class level declarations belong at the top of the class definition.


  • Never catch Exception or RuntimeException. Always catch the most specific type of exception thrown and handle the exception properly.


  • Avoid ascii art. This includes lining up method arguments that exceed a single line, indenting the right side of declaration assignment operators to make them all line up, and any other use of whitespace that does not indicate a semantic change. Using indentation to indicate a that code is within a code block (and within a certain scope) is required, of course.
  • Avoid extra blank lines unless it improves readability.

Format Configs

  1. Right click on project in package explorer, select "Properties"
  2. expand "Java Code Style"
  3. select "Formatter"
  4. check "Enable project specific settings"
  5. import eclipse format configuration file
Avoid temporary variables.
- The Elements of Programming Style (Kernighan & Plaugher)