Java Quick Guide

 
 
This guide contains useful Java information.







Java Code Conventions.



Information
The Java Code Conventions documentation can be found online on the java.sun.com website, see:
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

Other interesting Java programming style guidelines can be found at: http://geosoft.no/development/javastyle.html
http://www.joot.com/dave/writings/articles/style-guide

Sometimes you see pre-fix (= Hungarian notation) naming conventions applied to variable names to provide semantic meaning to the field. To explain what they mean an overview is given.

ATTENTION:
You should NOT use the Hungarian notation, which specifies type as part of the identifier, because it violates object oriented abstraction.

Pre-fix naming conventions (= Hungarian notation).

Pre-fixDescription
m_

or

_
m_ indicates class variable names. Seperates class variables from local variables.

public class Demo {
   public int m_height = 1;
   public int m_width = 10;

   public Demo(int height, int width) {
      m_height = height;
      m_width = width;
   }
}


Instead of m_ sometimes _ is used:

public class Demo {
   public int _height = 1;
   public int _width = 10;

   public Demo(int height, int width) {
      _height = height;
      _width = width;
   }
}


s String variables

public String sName;

b Boolean variables

public boolean bValid;

v Vector variables

public Vector vList;

e Enumeration variables

public Enumeration eSelection;

o Object variables

public Object oNextElement;

i Integer variables

public Integer iHeight;

  int variables have no pre-fix.

public int height;

ht Hashtable variables

public Hashtable htProperties;

exc Exception variables

public Exception excMessage;