Easy Tutorial
❮ C Dynamic Array C Pointer Detail ❯

Detailed Explanation of the Three-Tier Architecture

Category Programming Technology

I've always wanted to make a more complete and perfect summary. But after much thought, I didn't know how to start. It's said that the beginning is the most difficult part of everything. Today, I organized my messy thoughts, but they are still not well organized. Let's just talk about whatever comes to mind.

Beginners often don't understand:

In this blog, I will explain each of these points for everyone, and I apologize if my understanding is superficial!!!

Teacher Mi always emphasizes: Combine learning with life, connect learning with life, such a learning is called learning well, living well.

For the three-tier architecture, I pondered how to connect it with reality. Well, I suddenly had an "inspiration" last night. Do you still remember the story of the big bird and the small vegetable eating lamb skewers in the chapter of "Big Talk Design Patterns" - which led to a command pattern (of course, today is not about studying the command pattern). Waiter, chef, and purchaser.

Isn't this a typical three-tier architecture? (⊙ o ⊙) Ah! Haha (this will be explained later)

First, let's understand:


1, What is the three-tier architecture?

UI (Presentation Layer): Mainly refers to the interface that interacts with the user. It is used to receive user input data and display the data that the user needs after processing.

BLL: (Business Logic Layer): The bridge between the UI layer and the DAL layer. It implements business logic. Business logic specifically includes: verification, calculation, business rules, etc.

DAL: (Data Access Layer): Deals with the database. It mainly implements the addition, deletion, modification, and query of data. It submits the data stored in the database to the business layer, and at the same time, saves the data processed by the business layer into the database. (Of course, these operations are all based on the UI layer. User needs are reflected to the interface (UI), UI reflects to BLL, BLL reflects to DAL, DAL performs data operations, and then returns one by one until the data needed by the user is fed back to the user)

Each layer is responsible for its own tasks, so how should the three layers be connected?

  1. Single-direction reference (see the figure below)

  2. At this time, the entity layer (Entity) comes in. (Note: Of course, the role of the entity layer is not limited to this)

Entity (Entity Layer): It does not belong to any of the three layers, but it is an indispensable layer.

The role of Entity in the three-tier architecture:

However, for a large amount of data, using variables as parameters is a bit complicated because there are too many parameters, which are easy to get confused. For example: I want to pass employee information to the next layer, including: employee number, name, age, gender, salary... If we use variables as parameters, then the parameters in our method will be many, and it is very likely that the parameter matching will be confused when using them. At this time, if we use entities as parameters, it will be very convenient, and we don't have to consider the problem of parameter matching. We can directly use any attribute in the entity, which is very convenient. This also improves efficiency.

>

(Note: Why is it said that you can temporarily understand that each data table corresponds to an entity? Answer: Everyone knows that the purpose of our system is to provide services

❮ C Dynamic Array C Pointer Detail ❯