Odyssey Java Coding Standards

For consistency, all Java code in the Odyssey system should follow the following standards.

Version Control

Subversion is used for version control. The repository root is at svn+ssh://odyssey@core.cs/u/odyssey/svn/odyssey. Within this everything in the uw package is in a directory called uw, while everything in the zava package is in a directory called zava.

Each of these directories has a trunk subdirectory, which contains the code in actual use in the odyssey-2 package, and a branches subdirectory, which can be used for editing the code.

Update protocol is to copy from trunk to a directory in branches, update the branch, and test on a test server. Once the code has been tested and is considered ready to move to production, the changes can be merged back into the trunk.

Whitespace and Layout

Indentation is one tab per indent level. This allows each user to display indents at their preferred width.

The first line of a Javadoc comment starts with /** (of course). The last line consists of */ by itself. Lines in between do not have any special markings, but are indented one tab relative to the first and last line.

Parentheses stick to whatever is inside them, but tend to separate from whatever is outside them. The sticking is stronger than the separation, so multiple open or close parentheses in a row don't have spaces between them. Empty parentheses also have no space between them.

Curly braces go on the same line as any non-curly-brace part of the syntax of the structure of which they are a part. A curly brace will be on a line by itself only if it isn't associated with additional syntax. Empty curly braces have no space between them.

Here is an example that displays all of the above, except for the tab rule:

/** This is a method.
    @return The return value.
*/
public int countStuff (int P) {
    if ((P < 0) || (P % 2 == 1)) {
        int q = count0 (P);
        return count1 (P + q);
    } else {
        int q = count0 (P * 2);
        return count2 (P);
    }
}

protected Constructor () {}

-- IsaacMorland - 19 Mar 2007

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2007-03-19 - IsaacMorland
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback