


Summary of the principles and functions of Java three-tier architecture (picture)
This article mainly introduces the concepts and functions of Java three-tier architecture. Friends in need can refer to
Three-tier architecture
Three-tier architecture (3-tier application) In the usual sense, the three-tier architecture divides the entire business application into: Presentation layer (UI), business Logic layer (BLL), data access layer (DAL). The purpose of distinguishing levels is the idea of "high cohesion, low coupling".
ConceptIntroduction
1. Presentation layer (UI): In lay terms, it is the interface displayed to the user, that is What a user sees and gains when using a system.
2. Business logic layer (BLL): Operations for specific problems can also be said to be operations on the data layer and processing of data business logic.
3. Data Access Layer (DAL): Transactions done by this layer directly operate the database, for data addition, deletion, modification, search, etc.
Overview
In software architecture design, the hierarchical structure is the most common and important structure. The layered structure recommended by Microsoft is generally divided into three layers, from bottom to top: data access layer, business logic layer (also called domain layer), and presentation layer.
Three-tier structure principle:
In the three levels, the main functions and business logic of the system are processed in the business logic layer.
The so-called three-tier architecture adds an "intermediate layer" between the client and the database, also called component layer. The three-tier system mentioned here does not refer to the three physical layers. It does not mean simply placing three machines, which is the three-tier architecture. It is not only the B/S application that is the three-tier architecture. The three-tier system refers to the logical system. of three layers, even if these three layers are placed on one machine.
The application program of the three-tier system places business rules, data access, legality verification and other tasks in the middle layer for processing. Normally, the client does not directly interact with the database, but establishes a connection with the middle layer through COM/DCOM communication, and then interacts with the database through the middle layer.
The functions of each layer
1:Data data access layer: Mainly for original data (database or text file, etc.) ), rather than the original data, that is to say, it is the operation of data, not the database, specifically providing data services for the business logic layer or presentation layer.
2: Business logic Layer : It is mainly for the operation of specific problems. It can also be understood as the operation of the data layer and the processing of data business logic. If the data layer is the building blocks, then the logic layer is the construction of these building blocks.
3: Presentation layer: mainly represents WEB mode, and can also be expressed as WINFORM mode. WEB mode can also be expressed as: aspx, If the logic layer is quite powerful and complete, no matter how the presentation layer is defined and changed, the logic layer can provide services perfectly.
Specific distinction method
1: Data data access layer: It mainly depends on whether your data layer contains logical processing. In fact, its various Function mainly completes various operations on data files. Don't worry about other operations.
2: Business logic layer: Mainly responsible for the operation of the data layer. That is to say, combine some data layer operations.
3: Presentation layer: Mainly accepts user requests and returns data, providing the client with application access.
Presentation layer
is located in the outermost layer (top layer), closest to the user. Used to display data and receive data input by users, providing users with an interactive interface.
Business Logic Layer
The Business Logic Layer (Business Logic Layer) is undoubtedly the part that embodies the core value of the system architecture. Its focus is mainly on the formulation of business rules, the realization of business processes and other system designs related to business needs. In other words, it is related to the logic of the field (Domain) that the system responds to. Many times, the business logic layer is also called the domain layer.
For example, in the book "Patterns of Enterprise Application Architecture", Martin Fowler divides the entire architecture into three main layers: presentation layer, domain layer and data source layer. As a pioneer in domain-driven design, Eric Evans made a more detailed division of the business logic layer, subdividing it into the application layer and the domain layer, and further separated domain logic and domain logic solutions through layering. The business logic layer plays a key role in the system architecture. It is located between the data access layer and the presentation layer, and plays a linking role in data exchange. Since the layer is a weakly coupled structure, the dependence between layers is downward. The bottom layer is "ignorant" to the upper layer. Changing the design of the upper layer has no impact on the bottom layer it calls. If the idea of interface-oriented design is followed during layered design, then this downward dependence should also be a weak dependency. Therefore, without changing the interface definition, the ideal layered architecture should be a "drawer" architecture that supports extractability and replaceability. Because of this, the design of the business logic layer is particularly critical for an architecture that supports scalability because it plays two different roles. For the data access layer, it is the caller; for the presentation layer, it is the callee. The relationship between dependence and dependence is entangled in the business logic layer. How to realize the decoupling of dependency relationships is a task left to designers in addition to implementing business logic. Data layer Data access layer: Sometimes also called the persistence layer, its function is mainly responsible for database access, and can access database systems, binary files, Text document or XML document. To put it simply, it is to implement the operations of Select, Insert, Update, Delete on the data table. If you want to add ORM elements, it will include mapping between the object and the data table, as well as the persistence of the object entity. Advantages and Disadvantages Advantages 1. Developers can only focus on one layer of the entire structure; 2. It can easily replace the original layer implementation with a new one; 3. It can reduce the dependence between layers; 4. There are Conducive to standardization; 5. Conducive to the reuse of logic at each layer. 6. The structure is clearer 7. During later maintenance, the maintenance cost and time are greatly reduced Disadvantages 1. Reduced system performance. This is self-evident. If a hierarchical structure is not adopted, many businesses can directly access the database to obtain the corresponding data, but now it must be done through the middle layer. 2. Sometimes it will lead to cascading modifications. This modification is particularly reflected in the top-down direction. If a function needs to be added to the presentation layer, in order to ensure that its design conforms to the hierarchical structure, it may be necessary to add corresponding code to the corresponding business logic layer and data access layer. 3. Increased development costs. Rules The three-tier structure program does not mean that the project is divided into three modules: DAL, BLL, and WebUI. It is called three-tier. The following questions are in your Inside the project: 1. There are only a few (or no) SQL statements or stored procedures calls in UILyer, and these statements are guaranteed not to modify the data? 2. If Can your project still provide all functions at the Interface/API level if UILyer is removed? 3. Can your DAL be transplanted to other projects with similar environments? 4. Can the three modules be run on different servers? If not all answers are YES, then your project cannot be regarded as a three-tier program in the strict sense. Three The layer program has some rules that need to be agreed upon: 1. The most critical thing is that the UI layer can only be used as a shell and cannot contain any BizLogic processing procedures 2. The design should start from the BLL Starting from the starting point, not the UI. The BLL layer should implement all BizLogic on the API, in an object-oriented way 3. Whether the data layer is a simple SqlHelper, or with Mapping Classes should be system-independent to a certain degree of abstraction 4. Regardless of whether you use So when considering whether a project should apply a three-tier/multi-tier design, you must first consider whether it is really needed? In fact, most of them It is enough to open a WebApplication program, and there is no need to make it so complicated. The multi-layer structure is used to solve truly complex project requirements. The difference between and MVC MVC (Model-View-Controller) is a design pattern that we can use to create a distinction between domain objects and UI presentation layer objects. It is also at the architectural level. The same thing is that they all have a presentation layer, but the difference lies in the other two layers. The concept of COM+(
Enterprise Service) or Remoting,
or remote object technologies such as WebService
, regardless of whether they are actually deployed to different servers during deployment, at least such considerations must be made during design, and more Furthermore, you have to consider clustering multiple servers through load balancingController
is not defined in the three-tier architecture. This is what I think is the most different. MVC does not regard business logical access as two layers. This is the main difference between using a three-tier architecture or MVC to build a program. Of course. Model is also mentioned in the three-tier architecture, but the concept of Model
in the three-tier architecture is different from the concept of Model in MVC. The typical Model layer in the "three-tier" is composed of entity classes. In MVC, it is composed of business logic and access data.
The above is the detailed content of Summary of the principles and functions of Java three-tier architecture (picture). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.
