Summary of the three-layer structure

zhaozj2021-02-12  147

The three-layer architecture is an architectural design method for system-performing a functional abstraction, which divides the system into interface layers, business logic layers, and data access layers according to the function tasks of each module within the system. Each of our layers, divided into work. Each layer can also be pulled out of multiple levels.

Interface layer

Mainly, the display of the program interface is directly interacting with the user, such as accepting the user's input, display the result to the user, providing some friendly interaction information, etc., there are some relevant display logic, such as: What time to display a specific form , The display order of the form, and the like. This layer will pass the data received from the user into the service logic layer, and wait for the business layer to return the result, call the method provided by the business layer to complete the function of the required implementation, the specific implementation process is transparent to the interface of.

Business logic layer

Mainly responsible for handling business logic issues, all relevant business logic is returned to this layer. For example: whether the user wants to delete, whether there is a foreign key reference, and some data validity detection, etc., here is a method provided by the interface layer, that is to complete these similar business logic operations, it may be called to more Atomic operations provided by a data access layer.

Data Access Layer

Mainly responsible for direct interactions with databases, such as connecting the database, performing an operation of adding and deducting, and returning the result to the business layer, all of which are some basic data operations to provide integrated use to the business layer.

Example summary: When the business layer requires the query function, after the data access layer completes the record query, it is generally used to return these results in the form of record set object. If the business layer needs to use these results, it can be used directly. If it is the interface layer to display These query results, then return to the interface layer by the business layer, and display the query results on the interface by the interface layer operation record set. This may feel that there is a thoughts of ivity, and the object of the database should not appear above the business layer, but as long as the interface layer business layer is just simple browsing records, this program is still acceptable. Another implementation is to incorporate a container to the data access layer, put the result set in this container, then return to this container, use the container package record set, so that the business layer can be shielded to the database object. Operation, but the disadvantage of this solution is that the speed is slower than the direct operation record.

Layered code implementation

To achieve this hierarchical idea, you can use the class to implement, but if all classes are compiled into the same exe file, when the program becomes huge, it will modify the functionality of a part or upgrade the system in the future, the situation is It is difficult to control, and the new compilation must be re-published, and then it is necessary to re-write once when a project needs to go to a similar function, and it has to be reused. At the same time, developing such a system has to Control developers must develop in the same language.

This micro-software is proposed for the COM concept. COM is just a standard standard, not a real actual thing, and today I see ActiveX, OLE, and automation servers are specific implementations of this standard. By adopting component-type development, we can fully solve the problems encountered above. When there is a problem with a function of the system, just update this component and then release, COM can be developed by multiple language development.

转载请注明原文地址:https://www.9cbs.com/read-6311.html

New Post(0)