Java coding Standards

Coding standards for classes

Usually class name should be noun. Should starts with upper case letter and if it contain multiple
words every inner words also should start with capital letters.

Example:

String
StringBuffer
NumberFormat
CustomerInformation

Coding standards for Interfaces

Usually interface named should be adjective, starts with capital letters and if it contains multiple
words, every inner word also should starts with capital letter.

Example:

Runnable
Serializable
Clonable
Movable
Transferable
Workable

Coding standards with methods

Values should be either verbs or verb + noun combination.
Starts with lower case and every inner words starts with upper case(this convention is also called
camel case convention).

Example:

getName(), getMessage(), toString(), show(), display().

Coding standards for variables

Usually the variable starts with noun and every inner word should start with upper case i.e camel
case convention.

Example:

Name, rollno, bandwidth, totalNumber.

Coding standards for constants

It should be noun, it should contain only upper case letters and works are separated with underscores.

Example:

MAX_SIZE, MIN_PRIORITY, COLLEGE_NAME.

Java Been Coding Conventions

A java bean is a normal java class with private properties & public getter and setter methods.

Example:

public class StudentBeen 
{
    private String name;
    public String getName() 
    {
        return name;
    }
    public void setName(String name) 
    {
        this.name = name;
    }
}

Syntax for getterMethod

Compulsory it should be public & should not contain any arguments.
For the non boolean property xxx the following is syntax of getter method

public datatype getXxx()
{
return xxx;
}

For the boolean property xxx the following is the syntax

public boolean getXxx() or isXxx()
{
return xxx;
}

Syntax of setter Method

It should be public and return type should be void. For any propertyxxx

public void setXxx(datatype xxx)
{
This.xxx = xxx;
}

To register a listener

To register myActionListener x which of the following is valid coding convention.

public void addMyActionListener(myActionListener x);
public void addActionListener(myActionListener x);
public void registerMyActionListener(myActionListener x);

Similarly to un register myActionListener x which of the following are valid coding convention.

public void removeMyActionListener(myActionListener x);
public void removeActionListener(myActionListener x);
public void registerMyActionListener(myActionListener x);