My understanding of hierarchy (1)

Source: Internet
Author: User

I think everyone has read a lot about the concept of data layering. Here I will not talk about it again. I will not talk about the theory. I will only talk about it. The following content is mostly based on ASP. NET.

First, consider your own needs before using layering. don't look at other people's hierarchy to keep pace with the trend. such an idea will only make you more troublesome. my suggestion is that for small projects, periodic scaling or requirements will change frequently in the future. you can consider layered implementation .. if it is just a small and medium-sized enterprise website. requirements will not change frequently. in addition, most of the functions are previously done and can be directly aspx + Aspx. CS ..

Second, there is no standard for layering, and there is no rigid rule. The main purpose of layering is to make the project flexible and easy to manage and expand.CodeThere should be few or even no repeated code snippets. I have seen some layers. Each layer has repeated features or similar functional code .. these repeated functional modules re-write similar code because the passed parameters are different or the returned parameters are different .. such code can be completely divided into smaller modules. re-sealing and re-combination .. for example, drinks and tea, although they are different products, they do have the same material composition-water ..
Drinks can be divided into water and other substances,
Tea can be divided into water and tea
After the split, we can see that their common material is water! This is also the idea of object-oriented programming. To achieve maximum flexibility, we need to separate functions.

Finally, for ASP. net, the key to determining the performance is the size of network transmission. The larger the data transmission, the larger the performance consumption. the key to optimizing performance is database optimization. my suggestion is: cache your SQL statements as much as possible and execute them together. avoid the following actions:

Sqlcommand com =   New Sqlcommand ( " Select * From Table1 " , Conn );
Dr = Com.exe cutereader ();
Com. commandtext =   " Select * From Table2 " ;
Dr = Com.exe cutereader ();
Com. commandtext =   " Select * From table3 " ;
Dr = Com.exe cutereader ();

Reading data frequently consumes resources .. in fact, it can be written as a stored procedure, and then an execution is assigned to sqldatareader or dataset .. if sqldatareader has multiple tables, the nextresult () method of sqldatareader can operate multiple tables.
For data transmission at the database layer, dataset is widely used. if you need to use dataset to make a round-trip between the data layer and the business layer .. you can use the getchanges () function of dataset. it returns only changed records in dataset .. then add the changed dataset to the business layer with Merge ..

The above content is just to explain: Do not say that people say it is good, people can use it, the key is to suit themselves, can adapt to their own needs is the most important!

I am writing it here for the time being. I will try again later in a few days. Today, I am at risk of my life ..

Link:My understanding of hierarchy (2)

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.