JAVA Naming conventions

Source: Internet
Author: User
Tags naming convention

These days in the Java game, are all about the basics of Java basic things, here to tidy up:


Java is a language that distinguishes the case of letters (case-sensitive) and the naming conventions for packages, classes, variables, and so on in the Java language.

(a) The name of package (packages):

The package name should be made up of a lowercase word, such as net.ebseries.modules.


(ii) Class (class) naming:

The first letter of class is capitalized, usually a class name is synthesized from multiple words, requiring the first letter of each word to be capitalized, for example: DataFile or Infoparser.



(c) The name of the variable:

The name of the variable can be mixed in case, but the first character should be lowercase. The words are separated by uppercase letters, and the limit is underlined and the dollar symbol ($) is restricted, because this character has a special meaning for the inner class. such as: Inputfilesize.



(iv) Naming of Interface (interface):

Similar to the name of class.


(v) Naming of Static Final variable (equivalent to constant)

The name of the Static Final variable should be capitalized and indicate the full meaning, for example: Final maxuploadfilesize=1024.



(vi) Naming of methods

The first word of the method name should be a verb, and the case can be mixed, but the first letter should be lowercase. Within each method name, uppercase letters separate the words and limit the use of underscores. The name of the parameter must be the same as the variable's naming convention. Use meaningful parameters to name them, and, if possible, use the same names as the fields to be assigned:

 
   
  
  1. Setcounter (int size) {
  2. this.size = size;
  3. }

Naming the array

The array should always be named in the following way: byte[] buffer; instead of: Byte buffer[] (habitual problem only).

It should be noted that the name should be used as much as possible in the full English descriptor (there are exceptions). In addition, lowercase letters should generally be used, but the class name, interface name, and the first letter of any non-initial word should be capitalized.

The following points are summed up as follows: Try to use the full English descriptors, the use of terminology applicable to related fields, the use of mixed case to make the name readable, as few abbreviations as possible, but if used, to use wisely, and throughout the project unified, avoid the use of long names (less than 15 letters is a good idea), Avoid using a similar name, or just a different name, avoid underlining (except for static constants, etc.).


JAVA Naming conventions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.