Connection Between Layer 4 and Layer 3
Dependency: Relationship between three layers
Data access layer class: Access the database directly to add, delete, modify, and query basic records.
Business logic layer class: Use the related data category to implement the functions required by the user.
Interface Layer: After the control is deployed, the class at the business logic layer is called to implement the function.
Illustration:
Object Class: Data Transmission objects between layers
Why object classes are used as transmission objects between three layers?
ORM(Object link ing)
Object relational mapping (ORM for short) is an object-oriented class that does not match with a table in a relational database. It describes the ing metadata between objects and relationships, creates a persistent relationship between the class object in the program and the table of the relational database, which is used to describe the database table in the program. In essence, data is converted from one form to another. Orm is a broad concept that adapts to various types of data conversion between relational databases and applications.
Change the curriculum in the database. Course table design view
You can design a class to describe it like this:
Public Class Course Dim _courseid As String Dim _courseName As String Dim _courseCredit As String Public Property CourseID() As String Get Return _courseid End Get Set(value As String) _courseid = value End Set End Property Public Property CourseName() As String Get Return _courseName End Get Set(value As String) _courseName = value End Set End Property Public Property CourseCredit() As String Get Return _courseCredit End Get Set(value As String) _courseCredit = value End Set End PropertyEnd Class
Extract each field in the table as a class field (pay attention to type matching), encapsulate it as an attribute, and extract the table as a class. This type is called an entity class. This extraction process is called object link ORM ing Orm ., We design a corresponding entity class for each table in the database. This is equivalent to applying each table object in. net programs through class objects. Entity class objects are usually used in three-layer design.
Data transmission process:
Dependency between Layer 3 and entity class:
Advantages and disadvantages of layer 5:
Advantages:
1. The dependency between layers can be reduced;
2. developers can only pay attention to one of the layers in the entire structure;
3. It is easy to replace the original implementation with the new implementation;
4. facilitate the reuse of logic at each layer.
5. Increasing system flexibility is conducive to system expansion and standardization;
Disadvantages:
1. Reduced system performance. If the hierarchical structure is not used, many businesses can directly access the database to obtain the corresponding data, but now it must be done through the middle layer.
2. Cascade modifications may sometimes occur. This kind of modification is especially reflected in the top-down direction. If you need to add a function in the presentation layer, to ensure its design conforms to the hierarchical structure, you may need to add the corresponding code in the corresponding business logic layer and data access layer.
Summary:Layer-3 applications are implemented to divide programs and perform their respective duties at all levels of the system. The application can better adapt to the increasing complexity and flexibility requirements of enterprise-level applications, and achieve the requirements of expansion, maintenance and reuse through the principle of high cohesion and low coupling of software layers, this greatly improves the development efficiency.
Layer 3 theory II