Key Points of website project development-a practical project development experience

Source: Internet
Author: User

Key Points of website project development-a practical project development experience
1. When displaying the data to be selected, you must first check whether the data is massive data. For example, add 100 records in the drop-down box. Your users will not scold you.
2. Try not to restrict user input.
Verify the input content (regular expression)
Return NULL items for splitting and processing (string. Split (New String [] {'', ';'}, stringsplitoptions. removeemptyentries ))
Considering Chinese characters and full-width characters.
3. Set CSS in advance when designing the background interface. Generally, after the background interface is developed, the interface changes are not very large. You can simply process the CSS. Otherwise, you will be exhausted by changing the TD one by one.
4. unified planning of website Directories. for example, the background management is stored in the Administrator directory. in this way, the access permissions of individual directories can be restricted, and the directories that do not need to be indexed by search engines can also be restricted.
5. when developing a class on the BN layer, you must first consider whether the function of this class can be split into more specific child classes. Then you may need to create an abstract class and inherit it. however, most of the time, we do not consider this. When there are more and more methods in your class, you should consider whether it is necessary to split the class.
For example, we have a logic class for processing cars. At the beginning, there was no problem. However, when there were many types of cars, you would have to judge what type of cars they were, then, the corresponding method is called based on this type of car. in this case, we need to split this class. create an abstract class of a car (if there are many repeated logical implementations, you need to consider creating another car Interface), and then create an implementation class for each type of car, these implementation classes inherit the abstract classes and interfaces above. process the corresponding logic in each type of implementation class.
6. PASS Parameters only to the BN layer (do not construct SQL statement parameters, which should be constructed in the filter class of the corresponding table in the BN layer or data layer ).
7. when constructing an SQL statement based on the content entered by the user, you must use the method of passing parameters to effectively copy SQL injection attacks. it is to first construct an SQL statement with parameters, such as ID = @ ID, and then use sqlparameter to generate the parameters to be passed.

8. Disable the page viewstate when there are pages that may be accessed in large numbers or there are speed requirements for pages. The page control uses the control provided by HTML.

9. Do not use the new callback function of net2.0. If Ajax is required, JavaScript should be directly written to use XMLHTTP. Code is mostly used on the Internet.

10. when data is returned, do not use the dataset class, which is highly dependent on the database structure. to convert data to the corresponding DT and DV classes in the data layer (DT and DV classes can effectively prevent runtime problems caused by incorrect typing, an error is prompted during compilation .). and stored in the ilist object to return.

11. Parameters for unrestricted access to page links outside the background should be clear and clear, so that users can easily construct and search for indexed pages.

12. When we find that different pages contain the same part, we immediately want to split and create a custom control.

13.asp.net control event binding code requirements should be best defined in the post code page.

14. Specify a data source for datasource and place it in the databinding event of the control for processing.

15. When passing parameters between pages, if the intermediate part is suitable for JavaScript function processing, Chinese characters transmitted using JavaScript code may cause garbled characters. You can use the following JS Code for processing.

Function encodeutf8 (S1)

{

VaR S = escape (S1 );

VaR SA = S. Split ("% ");

VaR retv = "";

If (SA [0]! = "")

{

Retv = sa [0];

}

For (VAR I = 1; I <SA. length; I ++)

{

If (SA [I]. substring (0, 1) = "U ")

{

Retv + = hex2utf8 (str2hex (SA [I]. substring (1, 5 )));

}

Else retv + = "%" + SA [I];

}

Return retv;

}

Function str2hex (s)

{

VaR c = "";

VaR N;

VaR Ss = "0123456789 abcdef ";

VaR digs = "";

For (VAR I = 0; I <S. length; I ++)

{

C = S. charat (I );

N = ss. indexof (C );

Digs + = dec2dig (eval (n ));

}

// Return value;

Return digs;

}

Function dec2dig (N1)

{

VaR S = "";

VaR n2 = 0;

For (VAR I = 0; I <4; I ++)

{

N2 = math. Pow (2, 3-I );

If (N1> = n2)

{

S + = '1 ';

N1 = N1-N2;

}

Else

S + = '0 ';

}

Return S;

}

Function dig2dec (s)

{

VaR retv = 0;

If (S. Length = 4)

{

For (VAR I = 0; I <4; I ++)

{

Retv + = eval (S. charat (I) * Math. Pow (2, 3-I );

}

Return retv;

}

Return-1;

}

Function hex2utf8 (s)

{

VaR rets = "";

VaR temps = "";

VaR Ss = "";

If (S. Length = 16)

{

Temps = "1110" + S. substring (0, 4 );

Temps + = "10" + S. substring (4, 10 );

Temps + = "10" + S. substring (10, 16 );

VaR SSS = "0123456789 abcdef ";

For (VAR I = 0; I <3; I ++)

{

Rets + = "% ";

Ss = temps. substring (I * 8, (eval (I) + 1) * 8 );

Rets + = SSS. charat (dig2dec (ss. substring (0, 4 )));

Rets + = SSS. charat (dig2dec (ss. substring (4, 8 )));

}

Return rets;

}

Return "";

}

 

16. the search results sort different fields in different proportions. for example, the weekly and monthly statistics fields are sorted by 0.4 and 0.6 respectively. select weekcount, monthcount from tablename order by (weekcount * 0.4 + monthcount * 0.6)

17. Perform statistics on the clicks or views of each record in the displayed result list. We recommend that you click to go to a general page for statistics and then process the statistics as needed.

18. delete unused and useless code as soon as possible

19. It is best to use the // Method for comments of classes and methods to facilitate use by other developers.

20. do not process the obtained data in a specially constructed string format and use it as a return value or parameter. This restricts the data content. for example, the string format of "data;" cannot contain semicolons.

21. Do not save the background page data in the session and put it in viewstate. After the page is left, the data is automatically cleared. The session will not.

22. The construction of SQL statements, especially the special processing of query conditions, should be put into the filter class of the corresponding table at the data layer for later maintenance.

23. the DV class at the data layer is used to return data structure extensions. For example, for multi-table queries, you can add data attributes in DV to save other returned table fields. you can also create a new attribute to save the Data Objects of the sub-table to facilitate processing the data structures generated in similar situations such as parent and child tables. parentclassdv. getchildclassdv. fielddata

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.