Docs 2.0 Source Code Style Guide

Warning

This page is under construction!

Top


Revision History

Description Author Version Date
Initial Creation Scott Fehrman 1.0.0 September 2009

Top


This Document

This document provides instructions on how to "style" and "format" source files used within this project.

Top


Java

Class Names

All class names shall begin with a capital letter [A-Z] followed by a combination of lower and upper case letters.

Interface Names

All interface names shall begin with a capital letter [A-Z] followed by a combination of lower and upper case letters. The name shall end with the two upper case letters "IF".

Global Variables

All global variable shall begin with a single underscore "_" character followed by lowercase characters. An uppercase character may be used in the middle of the name to clarify its description. Underscore characters shall not be used in the middle of the name.

Examples

private Document _xmlDocument = null;
protected Map<String, ModelIF> _models = null;
protected Map<String, Map<String, String>> _mapCtxRelCtx = null;
protected Map<ConverterType, ConverterIF> _converters = null;

The referencing of a global variable shall be done by using only it's name, the use of this. shall not be used. Example:

Correct Incorrect
_myGlobalVar.methodName()
this._myGlobalVar.methodName()
System.out.println(_title);
System.out.println(this._title);

Local Variables

Only declare at the top of the method.

Method Names

Code Format

import placement

No Wildcarding

The use of a "wildcard" in an import statement shall not be used. Each Class will be added with a separate import statement.

The "ordering" (from top to bottom) of where an import shall be added is based on the package namespace. They shall be placed in the following order:

Category Example
Core Java java.util...
Java Extra/Extension javax.xml...
External / Third Party org.w3c...
Internal org.openptk...

The import statements shall be grouped together based on their package namespace. Each group of package import statements shall be separated by a blank line.


import java.io.IOException;

import java.net.URL;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import org.openptk.authen.AuthenticatorIF;
import org.openptk.client.BasicClient;
import org.openptk.client.ClientIF;
import org.openptk.crypto.CryptoIF;
import org.openptk.exception.ConfigurationException;

Top


JavaScript

Top


XML

Top


HTML

Top

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact