Naming agreement

zhaozj2021-02-17  51

Test: Naming Convention

We will discuss naming conventions throughout the standard, so let us first discuss several basic points: Use the full English descriptor that can accurately describe variables / fields / classes. For example, a name like FirstName, GrandTotal, or CorporateCustomer. Although the names such as X1, Y1 or Fn are very short, it is easy to enter, but we are difficult to know what they represent, what is the meaning of the result, thus making the code difficult to understand, maintain and improve. Terms in this field. If users say their "clients" is "customer", then the term Customer is used to name this class without the client. A mistake in many program developers will make a lot of common vocabulary when there is a perfect term if there is a perfect term in the industry or field. Use case-to-write mix to improve the readability of the name. Generally, lowercase letters, but the first letters of the names and interfaces, and the first letter of any intermediate words should be capitalized [kan97]. Try to use less abbreviations, but if you must use it, you should use it carefully. This means that a list of standard abbreviations should be retained, and it is wisely selected and consistent in use. For example, if you want to use abbreviations for words "Number", you can choose one from NBR, NO or NUM, indicating which one is adopted (which does not matter), and only uses this form. Avoid using long names (preferably no more than 15 letters). Although PhysicalorVirtualProductorService seems to be a good class name, this name is too long, you should consider re-giving it a short name, such as OFFERING. Avoid using similar or only on case in case. For example, variable name PersistentObject and PersistentObjects should not be used at the same time, as well as AnsqlDatabase and ANSQLDATABASE. Avoid using underscore as the first end of the name. The following scrubbing is the first letter of the letter usually reserves system, except for pre-processing definitions, generally not user named. More importantly, the underscore often causes trouble and difficult to enter, so try to avoid use.

转载请注明原文地址:https://www.9cbs.com/read-29640.html

New Post(0)