IDesign C # programming specifications

Source: Internet
Author: User

IDesign released the C # programming specification. The chicken shooter downloads and browses the code from Only4Gurus and is determined to take the time to translate the code for better learning.

The directory content is as follows:

1. Naming rules and Style Naming Conventions and Style
2 encoding Convention Coding Practices
3. Project Settings and Structure
4 Framework special guide Framework Specific Guidelines
4.1 Data Access
4.2 ASP. NET and Web Service ASP. NET and Web Services
4.3 Serialization
4.4 Multithreading
4.5 Remoting
4.6 Security
4.7 service components Enterprise Services
5 Resources

Today, only the naming rules are translated. the translated text and the original text are compared as follows, where the tip is appended ,:-)

 

Naming rules and styles
Naming Conventions and Style

1. Use the class and method namesPascal Style
Use Pascal casing for type and method names
Public class SomeClass
{
Public SomeMethod (){}
}
2. Use local variables and method parametersCamel Style
Use camel casing for local variable names and method arguments
Int number;
Void MyMethod (int someNumber)
{}
3. The interface name uses I as the prefix.
Prefix interface name with I
Interface IMyInterface
{..}
4. The private member variable uses m _ as the prefix.
Prefix private member variables with m _
Public class SomeClass
{
Private int m_Number;
}
5. The custom Attribute class name uses Attribute as the suffix.
Suffix custom attribute classes with Attribute.
6. Use Exception as the suffix for the custom Exception class name
Suffix M exception classes with Exception.
7. Use the verb-object naming method, such as ShowDialog ()
Name methods using verb-object pair, such as ShowDialog ()
8. A method with a return value should be named to indicate its return value, for example, GetObjectState ()
Methods with return values shoshould have a name describing the value returned, such as GetObjectState ().
9. use descriptive variable names.
Use descriptive variable names.
A) Avoid using single-letter variable names, such as I or t. Instead, use index or temp.
Avoid single character variable names, such as I or t. Use index or temp instead.
B) Avoid using public and protected membersHungarian naming convention.
Avoid using Hungarian notation for public or protected members.
C) do not use the abbreviation (for example, abbreviated number as num ).
Do not abbreviate words (such as num instead of number ).
10. Always use the C # predefined type, instead of the alias in the System namespace. For example, if you use object instead of Object, use string instead of String, and use int instead of Int32.
Always use C # predefined types rather than the aliases in the System namespace.
For example:
Object NOT Object
String NOT String
Int NOT Int32
11. For generic types, uppercase letters are used. Type is retained when the. NET Type is processed.
With generics, use capital letters for types. Reserve suffixing Type when dealing with the. NET type.
// Correct:
// Correct:
Public class upload list
// Avoid using:
// Avoid:
Public class upload list
12. Use meaningful namespace names, such as product names or company names.
Use meaningful namespaces such as the product name or the company name.
13. Avoid using the full name of the class, but use the using statement.
Avoid fully qualified type names. Use the using statement instead.
14. Avoid using the using statement in the namespace.
Avoid putting a using statement inside a namespace.
15. Put all the framework namespaces together, followed by custom or third-party namespaces.
Group all framework namespaces together and put custom or third party namespaces underneath.
Using System;
Using System. Collections;
Using System. ComponentModel;
Using System. Data;
Using MyCompany;
Using MyControls;
16. Use delegate inference. Do not explicitly instantiate the delegate.
Use delegate inference instead of explicit delegate instantiation
Delegate void SomeDelegate ();
Public void SomeMethod ()
{}
SomeDelegate someDelegate = SomeMethod;
17. strictly abide by the indent format.
Maintain strict indentation.
A) three spaces are used for indentation.
Use 3 spaces for indentation.
B) do not use tab or non-standard indentation, such as 1, 2, or 4 spaces.
Do not use tabs or non-standard indentation like 1, 2 or 4 spaces.
18. The annotation indentation is at the same level as the annotated code.
Indent comment at the same level of indentation as the code you are documenting.
19. All comments must be spelled out. Misspelled comments indicate a hasty development.
All comments shoshould pass spell checking. Misspelled comments indicate sloppy development.
20. All member variables should be defined in front, and a blank line should be opened between attributes or methods.
All member variables shocould be declared at the top, with one line separating them from the properties or methods.
Public class MyClass
{
Int m_Number;
String m_Name;

Public void SomeMethod1 ()
{}
Public void SomeMethod2 ()
{}
}
21. The definition of a local variable should be as close as possible to its initial use.
Declare a local variable as clo

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.