UIMA project logo
Apache UIMA Code Conventions
Apache UIMA

Search the site

 Apache UIMA Code Conventions

To improve the readability and maintainability of the Apache UIMA™ code, we have adopted the following code conventions. All UIMA developers should adhere to these guidelines when committing changes or submitting patches.

  • Use 2 spaces for indentation. No tabs!
  • Place open braces on the same line as the declaration, for example:
    		  public class Foo extends Bar {
    		    public static void main(String args[]) {
    		      try {
    		        for (int i = 0; i < args.length; i++) {
    		      catch(NumberFormatException e) {
  • Wrap lines longer than 100 characters. For wrapped lines, either use an indent of 8 characters or align with the expression at the same level on the previous line.
  • Within a class or interface, definitions should be ordered as follows:
    1. Class (static) variables
    2. Instance variables
    3. Constructors
    4. Methods
  • Do not use package imports (for example import org.apache.uima.*)
  • For other cases, we try to follow Sun's code conventions as much as possible: see https://java.sun.com/docs/codeconv

 For Eclipse Users

Eclipse users may download this preferences file: ApacheUima_EclipseCodeStylePrefs.xml and import this into Eclipse. (Window->Preferences, go to Java->Code Style->Formatter and click "Import..."). Once you have done this you can reformat your code by using Source->Format (Ctrl+Shift+F).

Also note that Eclipse will automatically format your import statements appropriately when you invoke Source -> Organize Imports (Ctrl+Shift+O).