Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning

This Style guide is unofficial as of yet. Please see the Code Contribution Guidelines page for our old code style recommendations, which are still currently in effect.

Table of Contents

Existing DSpace Java Style Guide

Per the Code Contribution Guidelines page (see "Coding Conventions" section), our existing style guide is listed as follows:

...

Because the Sun Java style guide is no longer maintained, it will not be keeping up with current Java style best practices, features, etc.  We should consider whether we continue to base our style off this outdated guide, use a more modern guide, or develop our own guide.

Proposed DSpace Java Style Guide (work-in-progress - not yet approved)

Bolded rules are a change from our current Style Guide.

  1. 4-space indents for Java, and 2-space indents for XML. NO TABS ALLOWED.
  2. K&R style braces

    Code Block
    if (code) {
      // code
    } else {
      // code
    }


  3. Do not use wildcard imports (e.g. import java.util.*)
  4. Write Javadocs for public methods and classes.

...

  1. Keep it short and to the point
    1. (UNDER DISCUSSION) Javadoc @author tags are optional, but should refer to an individual's name or handle (e.g. GitHub username) when included?
  2. Maximum length of lines is 120 characters.

  3. UTF-8 encoding is required
  4. Each source file must contain the required license header, e.g.

    Code Block
    /**
     * The contents of this file are subject to the license and copyright
     * detailed in the LICENSE and NOTICE files at the root of the source
     * tree and available online at
     *
     * http://www.dspace.org/license/
     */


Other

...

Java Style Guides

Google Java Style Guide

The Google Java Style Guide is at https://google.github.io/styleguide/javaguide.html

...