. Net official encoding methods and naming rules

Source: Internet
Author: User
Tags coding standards
Visual Studio
 
Encoding method
The coding method combines many aspects of software development. Although they generally have no impact on the functionality of the application, they are helpful in improving the understanding of the source code. All forms of source code are taken into account, including programming, script writing, markup, and query languages.
We do not recommend that you set a fixed encoding standard for the encoding method defined here. Instead, they are intended to serve as guidelines for coding standards for developing specific software projects.
The encoding method consists of three parts:
Name
Note
Format
Name
The naming scheme is the most influential help for understanding the logical flow of an application. The name should indicate "what" rather than "how ". By avoiding the name of the public basic implementation (which may change), you can retain the abstract layer that simplifies the complexity. For example, you can use GetNextStudent () instead of GetNextArrayElement ().
Naming rules are as follows: selecting the correct name may indicate the purpose of further analysis or definition. Make the name long enough to make sense, and be short enough to avoid being too long. The unique name is only used to differentiate items. Strong performance names are used to help people read; therefore, names that people can understand are meaningful. However, make sure that the selected name complies with the rules and standards of the applicable language.
The following are recommended naming methods.
Routine
Avoid obscure names that are easily subjective, such as AnalyzeThis () for routines or xxK8 for variables. Such a name will lead to ambiguity, not just abstraction.
In an object-oriented language, it is unnecessary to include a class name in the class attribute name, such as Book. BookTitle. Instead, use Book. Title.
Use the verb-noun method to name the routines that perform specific operations on a given object, such as CalculateInvoiceTotal ().
In languages that allow function overloading, all overloading should execute similar functions. For languages that do not allow function overloading, establish naming standards for the relationship between similar functions.
Variable
If appropriate, append the calculation qualifier (Avg, Sum, Min, Max, Index) at the end of the variable name ).
Use complementary pairs in variable names, such as min/max, begin/end, and open/close.
Since most names are constructed by concatenating several words, use a mix of upper and lower cases to simplify their reading. In addition, to help distinguish between variables and routines, use CalculateInvoiceTotal for the routine name. The first letter of each word is in uppercase. For variable names, use camel case sensitivity (documentFormatType). The first letter of each word except the first word is capitalized.

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.