This page outlines the coding conventions used in Jour. If you wish to contribute code to this project then the code will be expected to follow these conventions.

The purpose of having common coding conventions is to make the code easier to understand and therefore more easily maintained.

We use checkstyle to check as many coding conventions as possible. Things covered by checkstyle are only documented below if we feel that they require explanation. You can run checkstyle with the following target.

maven jour:checkstyle

Eclipse settings

If you use Eclipse 3 you can download and import configuration files. See Eclipse configuration reference

Unit tests

All code must have 100% automated test coverage using the JUnit testing framework. We strongly suggest that you write the code test-first but We'll be happy as long as there are full tests for everything. Run the tests with the following target.

maven jour:test

Code coverage (see Clover test coverage report) should be no less than


Project coding conventions outlines

1. Brackets

Brackets are mandatory, even for single line statements !

// Incorrect
if (expression)
    // some code

// Correct
if (expression) {
    // some code


2. Blank Spaces

keywords followed by a parenthesis should be separated by a space. Example :

while (true) {
    // some code


Blank space should appear after commas in argument lists. Binary operators should be separated from their operands by spaces :

a += c + d;
a = (a + b) / (c * d);

while (d++ = s++) {

printSize("size is " + foo + "\n");


3. Indentations

4 spaces. NO tabs . Period. We understand that a lot of you like to use tabs, but the fact of the matter is that in a distributed development environment, when the cvs commit messages get sent to a mailing list, they are almost impossible to read if you use tabs.


Javadoc SHOULD exist on all your class members (methods + class variables), including the private ones. Also, if you are working on existing code and there currently isn't a javadoc for that method/class/variable or whatever, then you should contribute and add it. This will improve the project as a whole.

Also add code comments when you think it's necessary (like assumptions), especially when the code is not obvious.

5. Author references

If you contribute to a file (code or documentation), add yourself to the top of the file (below the existing authors). For java files the preferred Javadoc format is:

@author devnickname


7. Class variables

Class variables should not have any prefix and must be referenced using the this object. Example :

public class SomeClass {
    private String someString;
    public void someMethod() {
        logger.debug("Value = " + this.someString);


8. Parameter names

Method parameters should not have any prefix. For example :

public void someMethod(String className) {


9. Line length

Avoid lines longer than 120 characters for Code, comments, ...

10. Versioning

All .java files should have a @version tag like the one below.

@version $Revision: 1.2 $ ($Author: vlads $)


11. Qualified imports

All import statements should containing the full class name of classes to import and should not use the "*" notation :

An example :

// Correct
import java.util.Date;

// Not correct
import java.util.*;


Fully qualified import statements make it much easier to maintain the source. When I'm trying to learn someone else's code, one of the first things I do is expand all the .* imports so that I can figure out what class came from where. If they're already expanded then it makes it much easier to understand the code.

A common complaint about this convention is "how will I know if an import isn't needed anymore?". The answer is, use a tool that warns you about this. Eclipse and IDEA can be configured to warn you about unused imports. If your editor doesn't perform this check then the maven build will check it for you.