Transcript
Page 1: Java Coding Standards

Java coding Standards

1. 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.

2. 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

3. 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 calledcamel case convention).Example: getName(), getMessage(), toString(), show(), display().4. 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.5. 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.6. 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 methodpublic datatype getXxx(){return xxx;}7. Syntax of setter Method: It should be public and return type should be void. For any propertyxxxpublic void setXxx(datatype xxx){This.xxx = xxx;}


Top Related