This document describes how developers and contributors should write code to be included into the main CIlib tree. The reasoning behind these conventions is mainly for consistency, readability and maintainability.

General code style and convention

All working files within the source tree of CIlib must adhere to the following conventions:

  • License Header: All source files will add the GPLv2 license header. NOTE: CIlib will not compile if the check for header information fails.
  • Trailing whitespaces: All trailing whitespaces must be removed.
    • Netbeans users should use the "Remove Trailing Whitespace" option under the "Source" menu item.
    • Eclipse users can use the Anyedit Eclipse Plugin to automatically remove trailing whitespace.
  • EOL: UNIX End Of Line characters are expected.

Style conventions applying to the project:

  • Indentation: No tabs are allowed for indentation! Use spaces.
  • Line wrapping: A column-width of 120 is to be used.

Java code

All classes are to be written following the JavaBeans Specification, barring a special reason. Such reasons include the class being a Singleton or Helper class that is not required during the XML to Java binding process.

The CIlib style for Java source files is generally accepted to be:

  • The names of classes / members / packages etc should make sense. If you are unsure, please consult the opinions of the development mailing list. Having a member, for example, named 'a' is useless.
  • All class members are to be given names in CamelCaps (which is the accepted Java style).
  • General code style is expected to look like the default style defined by Sun with regard to location of braces, puntuation etc.
  • All Java code is expected to have accompanying Javadoc comments.

Javadoc comments

It is expected that all classes in CIlib have the appropriate Javadoc 5 comments attached to each method. Javadoc is extremely important for CIlib as the project is a library and users will constantly be referring to the API. The normal conventions described by Sun regarding Javadoc should be followed.

For package level Javadoc, CIlib uses the JDK5+ package-info.java package information.

References: All code that is written that is derived from a published article etc, will have the appropriate BibTeX entry in the class level Javadocs. The BibTeX reference should be placed in a <pre></pre> environment. Such references are extremely important and should be available in the Javadoc.

An important note about the {@inheritDoc} tag: please do not use this tag for classes that are not in CIlib. For example, if you have a class that extends a class or implements an interface that is defined in the JDK, the {@inheritDoc} annotation will fail to generate the expected Javadoc. You should rewrite / paraphrase the Javadoc to make the intention apparent.