One. Comment 1 of the program code 1. The header of the stored procedure is noted that each stored procedure must write a comment, written at the forefront. Such as / * author: Billcreate Time: 2003-06-16 17: 04last Modify Time: 2003-06-16 17: 13version: 1.0.01action describe: Memo: * / 2. The internal annotation of the memory process within the stored procedure needs to add a comment on the situation, simply explain its function, design ideas, algorithms, etc. Such as: / * set nocount on * / 3. The head of the CS file comments Each .cs file must write a comment, write the front of the CS file. Such as / * file name: ClientServices.csStorage Path (Storage Path): CapitalNet_Mis / Entitydao / Author (Author): BillCreate Time: 2003-06-16 17: 04Last Modify Time (final modification Date and time): 2003-06-16 17: 13File Version: XXXXX 1.0.01File Action Describe (File Function Description): Customer Service Entity Access Layer File Memo: * / 4. Class Note For the detailed comments you defined, including the author, time, version revision, basic algorithms, such as: ///
Such as: // Draw the string as normal and let damforms do the work / * this is a test * / 1) Generally speaking, comment on need, concise. 2) Modify the code's annotation, when there is a second person to start modifying the code, a comment should be accounted for each modified code section, must include modifying people, modifying the time, and can also include modifying purposes, etc. 8. Other points 1) add annotations to the end of the above longer. Such as // for cycle ends. 2) Note must be concise and easy to understand. two. Objective accessibility design 1) Do not define classes of PUBLIC, which is quite important in the development of components. 2) Only the functions referenced by other classes are defined as a PUBLIC type function. 3) It is best not to use the public type member variable in the class (generally used attributes). 4) It is best not to use global variables. Some replacement methods can be used. three. Object naming specification 1. Naming Requirements 1) All named (class, functions, variables ..) require significance to clearly understand. 2) Avoid using the words such as the uncertain meaning of numbers directly in the code, try to use meaningful string values. Example: protected const string capen_title = "Bind Data to a ComboBox" 3) distinguish various variables and functions on the name. 2. Naming Convention 1) Constant Name Rules. A composite word that is generally used in uppercaseness is generally defined. Protected const string capen_title = "Bind Data To A ComboBOX" 2) field (variable), start opening a lower-write letter, the back of the meaningful English words begins in uppercase. Public String Strname, etc. 3) attributes, generally with uppercase letters, must have certain significance. Name; 4) Class name, meaningful compound English words that start with uppercase letters. The meaning of this class is also considered for the definition of the class name. For example, we divide the business rules, data, business interface, and data access layers, etc. in the project. I will give an Agent table to be renamed when processing in each layer: AgentData - àAgents - àagentr - àagentf (分: data entity, data access layer, business rules, business interface layers Naming) 5) The naming rule of the control, the naming of the control can begin (lowercase), with a meaningful English word; try to make abbreviations understand. Encountering new controls can be discussed.
For example: Button: btnupate Dropdownlist: Ddlstcity Label: LBLName DataGrid: GRDAGENT DATALIT: DLSTAGENT TEXTBOX: TXTNAME (etc.) 6) The name of the file name is starting with uppercase letters. DataAccess.cs four. Definition and Function Description of Data Sheets 1) The definition of the basic table is the database table that provides basic data with the business implementation of the business implementation. This type of country, currency, unit (COMPANY), Contact, Product, Bank, and so on. 2) The maintenance feature provided by the basic table provides additional, modification, deletion, and other maintenance functions for these basic tables. In these functions, the viewing function is important, to give multiple conditions for viewing features, so that you can view and reference the modules. 3) Definition of business form means database tables directly related to business, to save various business data, implementing various business functions, Contract, Project, Opportunity (Opportunity ), ContractPAIDLIST, etc. 4) The maintenance feature provided by the business table provides additional, modify, delete, view, and other maintenance functions for these business forms. Because these data are closely related to the business, a number of queries can be given. These services involve a lot of business logic, so you need to use the business logic layer to process the data in the business table. Fives. Project hierarchical definition and coding specification 1. Definition and Code Specification of Data Physical Layers This layer mainly defines the XML architecture (XSD) of the type data set. It is the memory representation of the database, and the establishment of architectural postcodes are automatically generated by the system.
1) Add a data set: Add à Add new item à data set; 2) Define Data Sheet Architecture: (1) Single Form: From "Server Explorer" to the design interface, the system will automatically generate a table Structure; (2) Multi-table form: method 1. Generate multiple tables in the above method, then manually add intervals association (if any); method II. Generate a basic table in the above method, then manually add other related fields, Make up a table; and his XML format this is this: XML Version = "1.0" encoding = "UTF-8"?> /> The code development specification of the business rules layer is not described later that only the following points should be paid attention to: 1) All business rules are implemented at this layer. 2) The calculation formula that is worth the field value for the calculating field to distinguish the field. 3) The interface should be as clear as possible. For example as follows: public static ContractPaidListData CalculateFirstPaid (string contractGuid) {ContractS contractS = new ContractS (); ContractData.ContractRow contract = contractS.GetContractByGuid1 (contractGuid) .Contract [0]; ContractChargeDetailData contractChargeDetailDS = new ContractChargeDetailData () ContractChargeDetailS contractChargeDetailS = new ContractChargeDetailS ( ); contractChargeDetailDS = contractChargeDetailS.GetContractChargeDetailByContractGuidAndOneFee (contractGuid); foreach (ContractChargeDetailData.ContractChargeDetailRow contractCharge in contractChargeDetailDS.ContractChargeDetail) {decimal price; int amount = 1;! if (contractCharge.IsRealPriceNull ()) {price = contractCharge.RealPrice * amount;} Else if (! contractcharge.isdiscountnull ()) {price = C ontractCharge.StandardPrice * contractCharge.Discount / 100 * amount;} else {price = contractCharge.StandardPrice * amount;} ContractPaidListData contractPaidDS = new ContractPaidListData (); ...... 5. Definition of business interface and coding specification This layer provides interfaces and intermediate interfaces. Under this layer, the data will possibly two flows: If this module has a business rule, the data will flow to the business rule layer; if this module does not have a business rule, the data will flow to the business interface layer. This layer is responsible for providing a data interface for the interface layer. According to the method of the interface function to be provided, the method to be implemented, including, INSERTXXX (Dataset), Updatexxx (Data Set), DELETEXXX (Dataset), LOADXXX () (for returning a data set), LOADXXXBYXX (Field 1, Field 2 ...) (for returning a data set according to a field or multiple fields). This layer is very small, just a definition of interface and delivery of data. If this module has a business rule, first instantiate the corresponding class in the business rule layer and call it to the corresponding method; if this module does not have a business rule, first instantiate an entity to access the layer corresponding to the class and call it. method. Examples are as follows: public sqldataadapter getCountry () {try {countrys countrys = new countrys (); sqldataadapter m_sql = countrys.getCountry (); return m_sql;} catCH (Exception E) {throw E;}} 6. The definition of the interface layer and the encoding specification interface layer provides a user interface and handles user operations. This layer should be separated from the background, that is, the role of interface code should be mainly to process user operations rather than business logic. Its purpose is to make future convenient replacement interfaces or even change the platform, such as turning from C / S to B / S or wants to be reversed. It works on this to work is the interface of the interface and the data entity, such as displaying data on the interface or synchronizing the interface data: public void initcontrol () {try {if (getRequest () == null) {Title.Text = "New:"; this.setTextNull (); btndel.visible = false;} else {title.text = "Modification, delete:"; btnsubmit.Value = "OK" BTNRESET.VISIBLE = False; citydata (); citydata (); getRequest ()); cityda.cities); citydata.city city = cityds.cities [0]; txtcityname.text = city.cityName; ... private void BTnsubmit_serverClick (Object sender, system.eventargs e) {TRY {if (! page.isvalid) {this.validateMessage ();} else {if (getRequest () == null) {cityData cityds = new citydata (); CityData.city city = cityds.cities.newcity (); city.guid = guidgenerator.getnewguid (); city.cityname = txtcityName.Text.trim (); ...... 6. Interface 1 of the project layers 1. The interface of the interface of the SQL layer is mainly to operate the SQL statement provided for the data access layer, such as queries, new, modified, deleted SQL, etc. for various ways. For parameters in the incoming method, the GET method is incoming one or several parameters that need to be used, the string value, INSERT, UPDATE, and DELETE methods are not passed to any parameters; and for return values, all methods are all returned A string. For example: public static System.String DeleteCity () public static System.String GetCities () public static System.String GetCitiesByAbbr (System.String cityName) public static System.String InsertCity () public static System.String UpdateCity () However, in the project Groups, generally only need to write a GET method. 2. The interface of the interface of the data access layer This is exposed to the upper layer call to do various operations for the database. For the LOAD method, first get the database connection and open, then use the method defined in the SQL definition layer and the just database connection to instantiate a SQLDataAdapter and return it as the return value. Return to turn the data connection before returning; for the Update method, first get the database connection and open, and then operate the data in the type data set. In operation, use the method defined in the SQL definition layer and the just database connection to instantiate a SQLCommand, and then assign the corresponding data value to the parameter and execute SQLCommand. The Boolean value is returned if the operation is completed. The data connection is turned off before returning. For example: public static System.Data.SqlClient.SqlDataAdapter GetCities () public static System.Data.SqlClient.SqlDataAdapter GetCitiesByAbbr (System.String cityName) public static System.Boolean UpdateCities (Capitalnet_MIS.Common.EntityDefinitions.CityData cityDS) 3. The interface of the business rules of the business rules is not a unified specification, depending on the actual needs. For example: public static Capitalnet_MIS.Common.EntityDefinitions.ContractPaidListData CalculateContractAmount (System.DateTime date1, System.DateTime date2, System.Decimal total, System.Decimal paidTotal, System.Decimal unPaidTotal) public static Capitalnet_MIS.Common.EntityDefinitions.ContractPaidListData CalculateFirstPaid (System . String contractGUID 4. The interface of the interface of the business interface is critical because this layer has a connection interface layer and the intermediate layer. For parameters in the incoming method, the GET method is incorporated into one or several parameters that need to be used, the string value, the UPDATE method is passed into a strong type of data set; for the return value, the Load method returns a type The data set, the UPDATE method returns a Boolean value.