Identifier naming specification
1. See the meaning of the name;
2. Hump naming law;
3. Underline naming method
4. Shortest length, maximum meaning
5. Do not use identifiers similar to numbers
Explanation 1, see the name to know the meaning, see the name to know what it means. For example, int age, you can see ages as they are represented. Double salary, see salary know is the meaning of salary. int C, see C We don't know anything, int c is not a good name.
Explanation 2, Hump naming law, we all know camel back hump, high and low, the identifier named so. such as Mybirthdayandparty, where birthday, and, party initials are size, the whole looks like a hump. In general, variable names, function names use the small hump nomenclature, where the initials are lowercase, and others follow the hump naming method. and class naming, such as the beginning of Studentservice,systemoutprint first letter is capitalized, that is, the big hump naming law.
Explanation 3, underline the naming method, such as My_birthday_and_party, the difference between the words is not with the uppercase distinction, but with the slip line _ distinguish.
The hump naming method and the underline naming method can be used according to different people's preferences, or between different development teams.
Explanation 4, the identifier uses the shortest length, but represents the most meaning. such as Printoutalltheclientsmonthendreports. Then you can get rid of vowels, such as prt_rpts (), although it means the most meaning, but this is like pregnancy, maybe some people do not see the pregnancy, At this point, you can add the necessary comments to explain the abbreviation is actually more misleading.
Explanation 5, number, we all know, such as school number, such as work number and so on, NUM1, num2, num3, why do not recommend the use of numbers. The biggest problem is to see the name does not know, others read the code can not understand, so that their development after a few months of their own do not know. Slowly it becomes the heavenly book.
Remember, people can not understand the code, is actually rubbish. The highest level of code is that anyone can read your code.
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