Java Naming Conventions

Source: Internet
Author: User
Java Naming Conventions-general Linux technology-Linux programming and kernel information. For details, refer to the following section. What are Java Naming Conventions?

Answer: 1. Use the complete descriptor to accurately describe variables, fields, or classes.

For example, the name can be FirstName, GrandTotal, or revoke ate Customer. Although names such as x1, y1, or fn are short and easy to enter, they do not provide any information to indicate what they represent. This makes it difficult to understand, maintain, and enhance the code.

2. Use terminology applicable to the domain.

If your users call their customers as customers, use the term Customer to replace the Client. Many developers have made the following mistake: when there are more appropriate terms in the industry or field, they are still thinking hard to create general terms for some concepts.

3. Cleverly and economically use abbreviations.

This indicates that you should maintain a list of standard short formats (abbreviations), select them wisely, and maintain a uniform value during use. For example, if you want to use the short format of the word arithmetic, select one of ar, ari, or art to record the selected abbreviation (which is not important in the end) and use only this one.

4. Use a mix of upper and lower cases to enhance the readability of the name.

Generally, lowercase letters should be used, but the first letter of the Class Name and interface name should be written in uppercase, and the first letter of all non-start words should also be written in uppercase.

5. Capital the first letter of the standard initials.

The name often contains the Standard abbreviation. For example, SQL indicates "Standard Query Language ". Names such as sqlDatabase indicating attributes or sQLDatabase indicating classes are easier to read than sQLDatabase and SQLDatabase.

6. Avoid long name (a maximum of 15 characters ).

Although the class name AllImplemented IterfacesAndSubclass may be a good class name (of course, it is exaggerated in this example), the name is obviously too long and should be renamed to a short name.

7. Avoid too similar names or case-sensitive differences.

The variable names myObject and myObjects should not be used at the same time, or both myOraDatabase and anORADatabase should be used.

Q: What should I do if I want to use the Tab key to move between input fields?

A: This feature is especially useful when users have to type a lot of text. The following program will show you how to switch the input focus between input fields:

Public boolean keyDown (Event evt, int key)
{
If (char) key = '\ t ')
{
Component current_field((componentincluevt.tar get;
If (current_filed! = Last_field)
Current_field.nextFocus ();
Else
First_field.requestFocus ();
Return true;
}
}

Note: When the last component last_field obtains the focus, press the Tab key to move the focus back to the first component first_field.
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.