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.
Ex:
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;
setCustomerName();
4.In case of variables:
Like
methods the camel case format should be used stating with a lower case letter.
Ex: buttonwidth;
accountBalance
mystring
5.Constants:
java
constants are created by marking variables as and final.
They
should be named using upper case letter with underscore (_) is the separator.
Ex:
MIN_HIGHT,MAX_HIGHT
Java Beans Naming
Conventions:
Java
Beans are java classes that have properties. All the properties must be
declared as the private (to get security). For every property there should be
getter and setter methods.The methods that change a property's value are called
setter methods, and the methods that retrieve a property's value are called getter
methods
Getter Methods: For every non – Boolean property ,the getter method prefix is get and for Boolean it can be get or is.
Getter method must be public and take no arguments and return the argument type of the setter method for that property.
Example –non Boolean: getXXX(); Example–Boolean: getXXX() or isXXX();
SetterMethods:The settermethod prefix is set.example setXXX();
Setter method signatures
must be marked public, with a void return
type
and an argument that represents
the property type.
Comments
Post a Comment