Sunday, February 8, 2009

Coding Standards

Java coding standards:
Sun recommended the following for the naming conventions.

1.In case of classes:
The first letter should be capitalized and if the several words are linked together to form the name ,the first letter of the inner words should be upper case.
For the classes the names should be nouns .
Ex:Student,Customer ,Employee etc.

2.In case of Interfaces:
For the interfaces the names should be adjective and follows camel case.
Runnable .Serializable,cloneable,Comparable,Movable etc

3.In case of Methods:
The first letter should be lower case and then normal camel case rules should be used.
The names should be verb –noun pairs
Ex: getBalance(); doCalculation(0;

4.In case of variables:
Like methods the camel case format should be used stating with a lower case letter.
Ex: buttonwidth;

java constants are created by marking variables as and final.
They should be named using upper case letter with unscore (_) is the saperator.

Java Beans Naming Conventions:
Java Beans are java classes that have properties.For every property there should be getter and setter methods.
All the properties must be declared as the private (to get security)
For every non – Boolean property will we should have public getXXX() method.
i.e the getter method is no argument method only.
For the Boolean properties we can have setter method public setXXX()


Post a Comment