Write a small summary of three-layer system procedures

zhaozj2021-02-16  59

According to the example of the example in 3.3 in VB, there are several problems, one is to return to the business or interface layer, performance and operation, with a collection package recordset. The type of record is returned. At the same time, the class object instantiation timing is more confusing, which is existing in the Sub Main, and also instantiated in the interface layer, while instantiating the object of the data access layer in the interface layer, so there is no complete compliance. Layer coding specification. At the same time, today I try to write a small-sized three-layer system applet has the following summary:

The hierarchical classification encoding can be referred to the example, but the recording set return method can be returned by the read-only recordset, and the timing of the object instantiation should be carried out by the principle of a layer of packaging, that is, the business layer is used in order to use The method of the data layer is instantiated to the low-layer object to complete the functionality to be completed by the business layer. The interface layer should only instantiate the business layer object, and the object of the data layer should not be instantiated. The method of calling the business layer object is called by the business layer object. The way the data is created, and the desired function is completed. The first layer is only responsible for one layer, there is no relationship between the compartment, but the disadvantage is that the coupling between the layers and layers is too strong.

For example, if the program is to insert a record, the process should first turn on the database connection, determine if this record is already in the database, if there is no existence, the insert record operation is performed. And the user will give the user.

Here, the appropriate hierarchical execution and object instances are as follows: The interface layer instantiates the business layer object, calls the business method inserted into the record, and instantiate a data layer object in the business layer object, call the open database method of the data layer object, Then call the query record method, query this record in the database, if there is no more operation, directly, the notification interface layer operation failed, if not, the insertion data method of the data layer object is called, returned after success Appropriate information. Here you can see that the interface layer should no longer instantiate a database object to perform a database connection, query, etc., and should only instance of a business layer object, and do these data operations by the business layer object, just use the business layer to provide The method will be, at the same time, the business layer object should provide sufficient functionality to the interface layer, and the data layer should also be the case.

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

New Post(0)