. Net naming rules and. net specifications

Source: Internet
Author: User

. Net naming rules and. net specifications

The naming rules are used to make the framework elements easy to understand and maintain consistency.

  • Case sensitivity

Case-sensitive rules for identifiers: To distinguish multiple words in the identifiers, the first letter of each word in the identifiers is capitalized. Do not use underscores, or use underscores anywhere in the identifier. There are two common methods: PascalCasing Pascal and camelCasing hump.

PascalCasing Convention is used for all identifiers except parameter names. It upper-case the first letter of each word in the identifier (including the first letter with a length of more than two characters), such as PeopertyDescriptor and Htmltag.

Two or more acronyms must be capitalized, such as RBGConnection and IOStream.

CamelCasing is only used for parameter names. It capitalized the first letter of the identifier except the first word. If the first letter is a acronym, it must be in lowercase, such as htmlTag and rbgConnection. For the camelCasing parameter, no matter how long the first word is, do not use uppercase letters for (Closed Form) composite words, such as endpoint, headfirst, Something, or Anyone.

  • General naming conventions

The choice of words should focus on easy-to-read names and readability, rather than conciseness (Hungarian naming method ).

Hungary naming: the data type in lower case is used as the prefix of the variable, such as uiCount. The other is to prefix the variable name to indicate the scope. Disadvantage: custom data types make it impossible for developers to find meaningful and consistent prefixes. Do not use acronyms and acronyms as part of the name of the identifier. However, you can also use acronyms that are well-known. For example: UI (User Interface), HTML (Hyertext markup Language ).

Avoid using a name unique to the programming language; use a semantic name for the Type name instead of a language-specific keyword; for example, GetLength is much better than GetInt; the common type of CLR should be used instead of the unique alias such as ToInt64 instead of ToLong.

For new versions of existing APIs, they should be as similar as the old ones. The suffix rather than the prefix should be used first, which is conducive to the combination of the two APIs when prompted intelligently. If the API name is the only meaningful name (industry standard), you can use a number as the suffix or enable a new name. For the differences between API versions, it is best not to use the Ex suffix.

  • Program set and DLL name

Namespace and DLL are not the same thing. A dll may contain multiple namespace names. It is best to use a representative name for the dll Assembly name, or you can use the following format:

<Company>. <Component>. dll

Namespace name template: <Company>. (<Product >|< Technology>) [. <Feature>] [. <Subnamespace>]

  • Class, structure, and interface

Classes and structures should be nouns or noun phrases, and they should represent entities in the system. If an interface represents the foundation of a type hierarchy, it should be a noun or noun phrase, if it indicates a certain ability, it should be an adjective or an adjective phrase, such as IComparable <T>.

The base class can be used as the suffix for the derived class of the class. The interface generally uses the "I" prefix.

For a generic type parameter, if there is only one parameter, you can use the "T" letter, or you can add "T" before the parameter name.

  • Common Types

Enumeration types are generally represented by words. It is best to use plural nouns for enumeration (marking enumeration) of bitfield types.

Methods and events generally use verbs or verb phrases. Do not use custom event processing functions. Most APIs can directly use EventHandler <T>.

The attribute must use nouns or adjectives. For the set attribute, the complex number should be used. You can use a type name to name the attribute. For example:

 

 

The preceding content is excerpted from. Net design specifications.


Net function naming rules

It is better to be consistent with your company's reading habits. If the company does not have one, it is consistent with your own reading habits. The first letter of the function name can be case-insensitive.

Net naming rules

Houser_Red is generally used for development.

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.