Idesign C # Programming Specification (1)

zhaozj2021-02-12  136

Idesign released a C # programming specification, and the chick shot was determined from Only4Gurus to see the time translation to better study.

The contents of the directory are as follows:

1 naming and style Naming Conventions and Style 2 coding practices Coding Practices 3 project setup and configuration Project Settings and Structure 4 Framework special guidance Framework Specific Guidelines 4.1 Data Access Data Access 4.2 ASP.NET and Web Service ASP.NET and Web Services 4.3 serial Serialization 4.4 Multithreading Multithreading 4.5 Remoting Remoting 4.6 Security Security 4.7 Services Components Enterprise Services 5 Resources Resources

Today, I only translated the naming rules, the translation and the original parties are as follows, and the TIP is attached, :-)

Naming rules and style Naming Conventions and Style

1. The class and method names using Pascal style Use Pascal casing for type and method names public class SomeClass {public SomeMethod () {}} 2. parameters using local variables and methods from camel Use camel casing for local variable names and method arguments int number ; void MyMethod (int someNumber) {} 3. interface name prefixed with I prefix interface name with I interface IMyInterface {..} 4. private member variables employed m_ prefix prefix private member variables with m_ public class SomeClass {private int m_number;} 5. Custom attribute class name uses Attribute as the suffix suffix custom attribute class with attribute. 6. Customized exception class name uses Exception as the suffix Suffix Custom Exception Classes with Exception. 7. Using the verb-object to naming methods, for example ShowDialog () name methods using verb-object pair, such as ShowDialog () 8. the method should return a value of the return value name represents, for example GetObjectState () methods with return values ​​should have a name describing the value returned, such as GetObjectState (). 9. Adopt a descriptive variable name. Use descriptive variable names. A) Avoid using single-letter variable names, such as i or t; but use index or temp. Avoid Single Character Variable Names, Such As I OR T. Use index or temp instead. B) Avoid using Hungarian nomenclature for public and protected members. Avoid Using Hungarian NOTATION for PUBLICOR PROTECTED MEMBERS. C) Do not use abbreviations (for example, Number abbreviations as num). Do Not Abbreviate Words (SUCH AS NUM INSTEAD OF Number). 10. Always use the C # predefined type instead of using the alias in the System namespace. For example, using Object does not have to use Object, use String without String, using int32 without INT32. Always Use C # predefined Types Rather Than The Aliases in The System Namespace. For example: Object Not Ibject String Not String Int Not Int32 11. For generics, the type is capitalized. Retain the suffix type when processing .NET type Type.

WIENERICS, USE Capital Letters for Types. RESERVE SUFFIXING TYPE WHEN DEALING WIEN DEALING WIEN DEALING WITH THE. Net TYPE. // Correct: // Correct: Public Class LinkedList / / Avoid:

// Avoid:

Public class linkedList

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 a 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. Place all Framework namespace names, put it from the defined or third-party namespace name.

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. Adopt commissioned, do not explicitly instantiate the delegation.

Use delegate Inference Instead of Explicit Delegate Instant

Delegate void somedlegate ();

Public void someMethod ()

{}

Somedlegate somedlegate = someMethod;

17. Strictly abide by the indentation format.

Maintain strict indeentation.

a) indentation adopts 3 spaces.

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. Note The code that is indent and its comment is on the same level.

Indent Comment At the Same Level of Indentation As The Code You Are Documenting.

19. All comments should be spell check. The annotated note indicates the development of the grassroots.

All Comments Should Pass Spell Checking. Misspelled Comments INDICATE SLOPPY development.

20. All member variables should be defined in front and attributes or methods.

All Member Variables Should Be Declared At The Top, With 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 local variables is as close as possible to its initial use. Declare a local variable as close as possible to it it .. 22. The file name should reflect the class it contains. A File Name SHOULD REFLECT The Class It Contains. 23. When using the Partial type and assigns a file per part, naming each file with a type name P and order. When using partial types and allocating a part per file, name each file after the type suffixed with a P and an ordinal number: // In MyClassP1.cs public partial class MyClass {} // In MyClassP2.cs public partial class MyClass {} 24. Left braces are always placed in the new row. ALWAYS Place An Open Curly Brace ({) in a new line. 25. Anonymous method mimics the layout of ordinary methods, and anonymous delegate definitions are placed in one line. WITH Anonymous Methods Mimic The Code Layout of a Regular Method, Aligned with The Anonymous Delegate Declaration. A) Compliance with the rules of the left bracers in the new row. Comply with placing an open curly brace in a new line delegate void SomeDelegate (string someString); // correct // Correct: public void InvokeMethod () {SomeDelegate someDelegate = delegate (string name) {MessageBox.Show (name);}; Somedlegate ("juval");} // avoid use: // Avoid Public Void InvokeMethod () {somedlegate somedlegate = delegate (String name) {messagebox.show (name);}; somedlegate ("juval");} 26. Anonymous methods without parameters use empty brackets. Use Empty Parenthesis On Parameter-Less Anonymous Methods A) Only when an anonymous method may be used for any delegate, the brackets are omitted.

Omit the parenthesis only if the anonymous method could have been used on any delegate delegate void SomeDelegate ();. // Correct SomeDelegate someDelegate1 = delegate () {MessageBox.Show ( "Hello");}; // Avoid SomeDelegate someDelegate1 = delegate {MessageBox.show ("Hello");};

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

New Post(0)