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;
JavaScript
XML
HTML |