11.15(eleven point one five)

1,什么是三层?UI(表现层): 主要是指与用户交互的界面。用于接收用户输入的数据和显示处理后用户需要的数据。

BLL:(业务逻辑层): UI层和DAL层之间的桥梁。实现业务逻辑。业务逻辑具体包含:验证、计算、业务规则等等。

DAL:(数据访问层): 与数据库打交道。主要实现对数据的增、删、改、查。将存储在数据库中的数据提交给业务层,同时将业务层处理的数据保存到数据库。(当然这些操作都是基于UI层的。用户的需求反映给界面(UI),UI反映给BLL,BLL反映给DAL,DAL进行数据的操作,操作后再一一返回,直到将用户所需数据反馈给用户)每一层都各负其责,那么该如何将三层联系起来呢?







1. What is the third floor? UI (presentation layer): it mainly refers to the interface interacting with users. It is used to receive the data input by the user and display the data required by the user after processing.

Bll: (business logic layer): the bridge between UI layer and DAL layer. Implement business logic. Business logic includes verification, calculation, business rules, etc.

Dal: (data access layer): dealing with databases. It mainly realizes the addition, deletion, modification and query of data. Submit the data stored in the database to the business layer, and save the data processed by the business layer to the database. (of course, these operations are based on the UI layer. The user’s needs are reflected to the interface (UI), the UI is reflected to the Bll, the Bll is reflected to the Dal, and the DAL operates the data, and then returns one by one until the data required by the user is fed back to the user.) each layer has its own responsibilities, so how to connect the three layers?

1. Single reference

2. At this time, the entity layer comes. (Note: of course, the role of entity layer is more than that)

Entity layer: it does not belong to any of the three layers, but it is an essential layer.

The role of entity in the three-tier architecture:

1. Realize the “encapsulation” in the object-oriented idea; 2. It runs through the three layers and transfers data between the three layers; (Note: specifically, the entity layer runs through the three layers to connect the three layers) 3. For beginners, it can be understood that each data table corresponds to an entity, that is, the fields in each data table correspond to the attributes in the entity (Note: of course, this is not the case. Why? 1 >, the entity we need may not exist in the entity corresponding to the data table; 2 >, we can put all fields in all data tables in one entity) 4. Data transfer between each layer (UI – & gt; Bll – & gt; DAL) (one-way) It is transferred by variables or entities as parameters, which constructs the relationship between the three layers and completes the realization of the function. However, for a large amount of data, it is complicated to use variables as parameters because there are too many parameters, which are easy to be confused. For example, I want to transfer employee information to the lower level, including employee number, name, age, gender, salary If variables are used as parameters, there will be many parameters in our method. It is very possible to confuse parameter matching when using them. At this time, it will be convenient to use entities as parameters without considering the problem of parameter matching. It is convenient to use which attribute in entities directly. This also improves efficiency.