Two-layer model:
The two-layer model is designed as the display layer and data access layer. The display layer is the user interface of the application (. aspx) and the Code hiding class (. CS), the data access layer is used to process the interaction between applications and databases, external web services, and so on. This is a lightweight model developed by Asp.net, which is relatively easy to implement. Therefore, the two-layer architecture model is very suitable for projects with simple business logic (haha, so don't hear people say that the three layers are good, so the three layers of the brain are used ....).
Layer-3 model:
A layer-3 Model adds a business layer on the basis of two layers. When a project needs to implement complicated business logic, if we still use two layers, We will hide the code class at the display layer (. CS) becomes very huge, because all business logic must be implemented in this, so that some code hidden classes may be as many as thousands of lines, maintenance and modification will crash ..... Another problem is that in the two layers, we put the data in the database into the able or dataset, and then directly pay some of the fields as the data source to the display controls such as the gridview (for example, label1.text = DT. rows [0] ["ID"]. tostring (). If we modify a field in the database (for example, the ID field above ), then we have to find the code using this field in the thousands of lines of code and correct it. The workload can be imagined, in actual program development, changes in requirements and design changes are inevitable. At this time, we can separate the application's business logic implementation and write it in a separate class, so that the business layer is born. The data displayed on the display layer is directly from the business logic layer, and the data on the business logic layer is from the database, which greatly reduces coupling, and the code will become simpler and easier to maintain (it seems that functional decomposition is a good way to solve complex problems ). The functions of the three layers are as follows: 1. The display layer only displays the labels and interfaces that interact with the business layer. 2. the business logic layer is responsible for processing data according to business rules so that the data can be provided to the display layer. 3. The role of the data access layer remains unchanged in the two-layer architecture. It is still responsible for retrieving data from the database for the service layer to process.