naming conventions are determined before we write Code . This article is in idesign (www.idesign.net) A document circulating on the Internet (C # Coding Standard Version 2.1) .
Benefits of using naming conventions:
In the Code DaquanIIThe authors explain the benefits of many naming conventions:
L requires you to follow more rules. By making a global decision rather than making many local decisions, you can focus on the more important features of the Code.
L helps deliver knowledge between projects. The similarity of names allows you to easily and confidently understand what unfamiliar variables should have done.
L helps you learn code faster in new projects. You don't need to know what specifications are in the code of other team members, but only need to face a group of more consistent code.
L helps reduce name growth. Without naming rules, it is easy to give two different names to the same object. This will confuse those who read this code.
L makes up for the shortcomings of programming language .
LEmphasize the relationship between related variables.
The key is that using any rule is better than having no rule. The existence of rules adds a structure for your code, reducing the amount of things you need to consider.
Naming rules:
1.UsePascalNaming classes and methods. The enumerated type ends with a plural number.
Public Class Creditcard
{
Public StringGetcardname ()
}
2.UseCamelTo name local variables and method parameters. Its name should be irrelevant to the underlying data type and reflect the things represented by the variable.
Int Cardcount;
Public String Getcardname ( String CardType)
{}
3.Interface prefix I.
Interface Iservice {}
4. Add the prefix cursor to the private member variable M _. use other parts of the name Pascal naming method.
Public Class Creditcard
{
Private StringM_cardname;
}
5. Custom Attributes plus attributes attribute .
6. custom exception plus suffix exception .
7. the method is named by a verb-object phrase. For example, showdialog ()
8.The method name with a return value should contain a description of the return value.
9.Use meaningful variable names.
L do not use a single character as the variable name
L do not use Hungary name Public or protected member
LDo not Abbreviated Words
10.Use meaningful namespaces, such as product names and company names.