Three-tier architecture and MVC pattern

Source: Internet
Author: User
aboutThe three-tier architecture of the three-tier architecture (3-tier application) is to divide the entire business application into the presentation layer (UI), the Business Logic layer (BLL), the data Access Layer (DAL). The purpose of distinguishing hierarchy is to think of "high cohesion, low coupling".
1, the performance layer (UI): Popular speaking is to show the user interface, that is, the user in the use of a system when he saw the proceeds.
2, Business Logic Layer (BLL): The operation of specific problems, it can be said that the operation of the data layer, the data business logic processing.
3, data access Layer (DAL): This layer of transactions directly operate the database, for the data increase, delete, change, check. [edit this paragraph] In software architecture design, layered structure is the most common and most important structure. The layered structure recommended by Microsoft is generally divided into three layers, from bottom to top: Data access layer, business logic layer (or domain layer), presentation layer.
Three-layer structure principle:
At 3 levels, the main functions and business logic of the system are processed in the business logic layer.
The so-called three-tier architecture is to add a "middle layer" between the client and the database, also known as the component layer. The three-tier system, as described here, not refers to the physical three layer, is not simply placed three machines is three-tier architecture, and not only B/s application is three-tier architecture, three-level refers to the logical three layer, even if the three layers placed on a machine.
Three-tier applications put business rules, data access, validation, and other work into the middle tier for processing. Typically, the client does not interact directly with the database, but through com/dcom communication to the middle tier and then through the middle tier to the database.
   Presentation Layer
  
At the outermost (top), closest to the user. Used to display data and receive data entered by the user, providing an interactive interface for the user.
   Business Logic Layer
  
The Business Logic layer (Business Logic Layer) is undoubtedly the part of the system architecture that embodies the core value. Its focus is mainly on the development of business rules, the implementation of business processes and other business requirements related to the system design, that is, it is related to the domain of the system (domain) logic, and many times, the business logic layer is called the domain layer. For example, Martin Fowler, in the book Patterns of Enterprise Application architecture, divides the entire architecture into three main layers: the presentation layer, the domain layer, and the data source layer. Eric Evans, the pioneer of domain-driven design, makes a more detailed division of the business Logic layer, divided into application and domain layers, and further separates domain logic from domain logic solutions by layering.
The position of the business logic layer in the architecture is critical, it is in the middle of the data access layer and the presentation layer, and it plays the role of the connecting link in the data exchange. Because the layer is a weakly coupled structure, the dependency between the layers is downward, the bottom layer is "ignorant" to the upper layer, and changing the top design has no effect on the underlying level of the call. If you follow the idea of interface-oriented design in layered design, this downward dependency should also be a weak dependency. Thus, without changing the definition of the interface, the ideal layered architecture should be a "drawer" architecture that supports the removable, replaceable type. Because of this, the design of the business logic layer is particularly critical to support an extensible architecture, because it plays two different roles. It is the caller for the data access layer, but it is the caller for the presentation layer. Dependence and dependency are entangled in the business logic layer, how to realize the decoupling of dependency is the task left to the designer except to realize the business logic.
   Data tier
  
Data access layer: sometimes called the persistence layer, its function is mainly responsible for database access, can access the database system, binary files, text documents or XML documents.
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.[edit this paragraph]
Advantages and Disadvantages :
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.
   Disadvantages:
1, reduce the performance of the system. This is self-evident. If you do not use a layered structure, many businesses can visit the database directly to obtain the appropriate data, but now must be done through the middle tier.
2, sometimes lead to cascading changes. This change is especially true in the top-down direction. If you need to add a feature to the presentation layer, to ensure that its design conforms to a layered structure, you may need to add code to the appropriate business logic layer and data access layer. [ edit this paragraph]
rules Three-tier structure of the program is not to say that the project into the Dal, BLL, WebUI three modules are called three layers, the following several issues in your project:
1. There are only a few (or no) SQL statements or stored procedure calls inside the Uilayer, and these statements guarantee that the data will not be modified?
2. If you take the Uilayer off, can your project provide all the features at the INTERFACE/API level?
3. Can your DAL be ported to other similar environment projects?
4. Three modules, which can be run on separate servers?
If not all of the answers are yes, then your project is not strictly a three-tier program. The three-tier program has some rules to follow:
1. Most critical, the UI layer can only be used as a shell and cannot contain any bizlogic process
2. Design should start from BLL, not UI. The BLL layer should implement all bizlogic on the API, in an object-oriented way
3. Regardless of whether the data layer is a simple sqlhelper or with mapping classes, it should be in a certain degree of abstraction to achieve system-independent
4. Whatever Using COM + (Enterprise Service), or remoting, or remote object technology such as webservice, regardless of whether the deployment is actually deployed to different servers, at least in the design of the time to do such considerations, farther, Also consider that multiple servers are clustered by load balancing
So consider whether a project should apply a three-tier/multi-tier design, and consider whether it really needs to be considered. In fact, most programs open a webapplication is enough, there is no need to do so complex. and multilayer structure, is used to address truly complex project requirements. [edit this paragraph]
The difference between and MVC MVC (Model model-View view-Controller Controller) is a design pattern that we can use to create a distinction between the domain object and the UI presentation layer object. The
is also architecture-level, and the same place is that they all have a presentation layer, but they differ in the other two layers. The
does not define the concept of controler in the three-tier architecture. This is the most different place I think. MVC does not see the logical access of the business as two tiers, which is the main difference between a three-tier architecture or an MVC Setup program. Of course. In the three layer also mentioned model, but the three-tier architecture model concept and MVC model is not the same, "three layer" in the typical model layer is already entity classes, and MVC, is composed of business logic and access to data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.