In software architecture design, layered structure is the most common and most important structure. Microsoft's recommended layered structure is generally divided into three layers, from the bottom to the following: Data access layer, business logic layer (or to become a domain layer), the presentation layer, as shown in the figure:
Fig. 1:3 Layered Structure
Data access layer: sometimes called the persistence layer, its function is mainly responsible for database access. The simple argument is to implement the select,insert,update,delete of the datasheet. If you want to add an ORM element, you will include the mapping between the object and the datasheet, and the persistence of the object entity. In the PetShop data Access layer, ORM is not used, resulting in an increase in code volume that can be seen as a major failure in the overall design implementation.
Business Logic Layer: The core of the entire system, it is related to the business (domain) of the system. In the case of PetShop, the relevant design of the business logic layer is related to the logic of the online pet shop, such as searching for pets, placing orders, adding pets to shopping carts and so on. If access to the database is involved, call the data access layer.
Presentation layer: The UI part of the system that is responsible for the interaction of the user with the entire system. In this layer, the ideal state is not to include the system's business logic. The logical code in the presentation layer, only related to the interface element. In PetShop, it is designed using asp.net, so it contains a number of Web controls and related logic.
What is the advantage of layered structure? Martin Fowler the answer in the book Patterns of Enterprise Application Architecture:
1, developers can only focus on the entire structure of one of the layers;
2, can be easily replaced by the new implementation of the original level of implementation;
3, can reduce the layer and the dependence between layers;
4, conducive to standardization;
5, conducive to the reuse of the logic of each layer.