Tags

Feb 22, 2012

Standard Naming Conventions in Java

There are a set of standard conventions which should be followed.


Class Naming
1) The class and interface names should start with Capital letters. A few examples of good class names is:
Car
Customer

Package Naming
2) The naming convention for package names says that they should start from the reverse of the domain name of your company.
com.companyname.productName.util.StringUtil
com.mycompany.productName.controller.HomeeController

Do note that all characters in the package names are in small letters.

Variables Naming
3) The variables should have a naming convention of
a) The first letter should be small letter
b) Every word in the variable names should start with a capital letter

Method Naming
4) The method names Starting with small letter and every other word staring with Capital letter.e.g.
checkUser()
addUser()

Constants Naming
5) The constants which are declared as public static final in Java should have all letters as capital and the words within the constant should be separated by _(underscore) character as:
DATE_PATTERN

Note: Same naming conventions should be used across the Java application.

1 comment: