20151009
Program Writing specification
1. Code writing Rules:
1), use the interface as much as possible, and then implement the interface using the class.
2), key statement write comments
3), avoid writing more than 5 parameters of the method, if you want to pass multiple parameters, use the structure
4), avoid the code size of the try... catch ... Module
5), avoid placing multiple classes in the same file
6),switch statement must have the default statement to handle the unexpected situation
7), build and build a long string, be sure to use the StringBuilder type (variable character sequence) instead of using string
8),if statement should be included with {} .
2. Naming specification
1), using Pascal rules to name methods and types
Pascal rule: The first letter is capitalized, and the first letter of the subsequent join word is also capitalized
Such as:
public class DataGrid { public void DataBind { ... } } |
2), using the Camel rules to name the parameters of local variables and methods
Pascal rule: First letter lowercase for first word
Such as:
String strUserName public void AddUser (String strUserID, byte[] bypassword); |
3), all member variables preceded by the prefix "_"
For example, declaring a private member variable in a public class DataBase
public class DataBase { Private string _connectionstring; } |
4), the name of the interface plus "I"
Such as: Create a public interface iconvertible
public interface IConvertible { Byte ToByte (); } |
5), the name of the method, it is generally named as the verb-bin phrase
For example: create CreateFile and GetPath methods in public class File
public class File { public void CreateFile (String strFilePath) { ... } public void GetPath (string path) { ... } } |
6), all member variables declared at the top of the class
Such as:
public class Product { Private string _productid; Private string _productname public void Addproduct (string strproductid, String strproductname) { ... } } |
7), naming namespaces with meaningful names, such as company name, product name
Such as:
Namespace Zivsoft// company name { ... } Namespace ERP// product naming { ... } |
8), when using a control value, try to name the local variable
Such as:
public string GetTitle () { String title = Lbl_title.text; Return title; } |
20151009 C # First program writing specification