Jump to: navigation, search

Difference between revisions of "Jetty/Contributor/Coding Standards"

 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Jetty Contributors}}
+
{{Jetty Contributor}}
 +
 
 +
{{Jetty Redirect|http://www.eclipse.org/jetty/documentation/current/coding-standards.html}}
  
 
==Code Formatting==
 
==Code Formatting==
  
Jetty uses the code formatting as specified in the following project.
+
Jetty uses the code formatting the following project specifies.
  
* http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/admin/jetty-eclipse-java-format.xml
+
* http://git.eclipse.org/c/jetty/org.eclipse.jetty.admin.git/tree/jetty-eclipse-java-format.xml
  
 
==Code Templates==
 
==Code Templates==
Line 11: Line 13:
 
Jetty specifies the following code templates for use by the project developers.
 
Jetty specifies the following code templates for use by the project developers.
  
* http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/admin/jetty-eclipse-codetemplates.xml
+
* http://git.eclipse.org/c/jetty/org.eclipse.jetty.admin.git/tree/jetty-eclipse-codetemplates.xml
  
 
==Code Conventions==
 
==Code Conventions==
  
The following is an example of the Java formatting and naming styles to be applied to Jetty:
+
The following is an example of the Java formatting and naming styles to apply to Jetty:
  
 
<source lang="java">
 
<source lang="java">

Latest revision as of 14:45, 23 April 2013



Code Formatting

Jetty uses the code formatting the following project specifies.

Code Templates

Jetty specifies the following code templates for use by the project developers.

Code Conventions

The following is an example of the Java formatting and naming styles to apply to Jetty:

import some.exact.ClassName;      // GOOD
import some.wildcard.package.*;   // BAD!
 
package org.always.have.a.package;
 
/* --------------------------------------------------------- */
/** Always have some javadoc
 */
class MyClassName
{
    // indent by 4 spaces.
    // use spaced to indent
    // The code must format OK with default tabsize of 8.
 
    private static final int ALL_CAPS_FOR_PUBLIC_CONSTANTS=1;
 
    // Field prefixed with __ for static of _ for normal fields.
    // This convention is no longer mandatory, but any given
    // class should either consistently use this style or not.
    private static String __staticField;
    private Object _privateField;
 
 
    // use getters and setters rather than public fields.
    public void setPrivateField(Object privateField)
    {
        _privateField=privateField;
    }
 
    public Object getPrivateField()
    {
        return _privateField;
    }
 
    public void doSomething()
        throws SomeException
    {
        Object local_variable = _privateField;
        if (local_variable==null)
        {
             // do Something
        }
    }
}