Warning: session_start(): open(C:\Windows\temp\sess_i2rqn8khf5tb0agjf22t5l22u3, O_RDWR) failed: Invalid argument (22) in D:\web\ktbrain\wp-content\plugins\wpforo\wpf-includes\class-notices.php on line 16
Coding Standards-II – ktbrain

Coding Standards-II

Naming Conventions
Java Programs are more understandable by providing meaningful names for variables, methods, classes, packages, and interfaces.
it is very important to keep in mind the following points.

Naming Conventions for Classes and Interfaces

  • A Class name should be noun and the first letter of each internal word should be Capitalized.
  • A class name should be simple, descriptive and  acronyms abbreviations should be avoided. like EmpDetails.
  • Apart from classes, an interface name should be Capialized. The interface name should be an adjective. like Action and WindowListener are adjectives representing an interface name.

Naming Conventions for Methods

  • A Method name should be verb, in mixed case with the first letter in lowercase and then normal`camelCase rules should be followed. like display,getCustomer.

Naming Conventions for Variables

  • A variable name should be short and descriptive so that it conveys the functionality of the variable.
  • A variable name should be written in lowercase letters. In case, if multiple words are used, then the first letter of the variable name should be in lowercase and the first letter of the rest of words should be in Uppercase. like totalCalculate,printResult.

Naming Conventions for Constants

  •   The names of variables declared as constants or ANSI constants should be in uppercase with each word separated by an underscore(_) like MAX_VAL,MIN_VAl.
  • Constants in Java are created using static and final keywords.

Naming Conventions for JavaBeans

JavaBean classes use accessors(setter methods) and mutators(getter methods).The methods that can change a property’s value are called setter methods and those methods that can retrieve a property’s value are called getter methods. some rules

  • The getter method’s prefix must be get,if the property is not boolean type.
  • The getter method’s prefix can be either is or get,if the propety is of boolean type.
  • The setter method’s prefix must be set.
  • The signature of a setter method must be public, with void as return type, and an argument that represents the property type.
  • The signature of a getter method must be public, with no argument, and a return type matching the setter method of that property.
  • To complete the name of a getter or setter method, the first letter of a property  name is in uppercase and then the appropriate prefix, get or set, is appended. Like  public void setName(String name),public String getName(),public boolean isValid().













Leave a Reply

Your email address will not be published. Required fields are marked *

Warning: Unknown: open(C:\Windows\temp\sess_i2rqn8khf5tb0agjf22t5l22u3, O_RDWR) failed: Invalid argument (22) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\Windows\temp) in Unknown on line 0