Introduction to an easy-to-understand three-tier architecture

Source: Internet
Author: User
(From the Internet to find an easy-to-understand introduction to the three-tier architecture, address: http://zhidao.baidu.com/question/29476722.html? SI = 1)

Three layers, generally including:

Data access layer: Also called dataaccess layer and Dal (dataaccess layer). This layer is used to deal with databases or other files,

Business logic layer: also called the middle layer, bussiness logical layer, or bussiness rule (business rule), which processes business logic.

Appearance layer: I do not remember the abbreviation "p". It starts with "P". This layer mainly deals with users, that is, interfaces. For example, it is web or winform.

For example, you need to make a simple function: Insert a student record into the database.

Appearance layer: It only processes how your interface should be displayed, such as the layout of the Control. Another major reason is to read the data in the control on the interface. The main task at this layer is to obtain data from the outside. Of course, there are some simple judgments. For example, to judge which data cannot be empty, it must be input.
Then, an access request from the middle layer is called and transferred through parameters.

The middle layer receives data from the appearance house. Here we will make a judgment on the Business series. For example, if a person over 20 years old is judged to be able to store a database, he or she cares about the business. He calls the data access layer method through the data in the business logic layer.

The data access layer only deals with databases (it can also deal with files. After all, it is not the only place where data is stored ). The database access layer does not make too many judgments on the business logic. Its task is to store the data transmitted from the middle layer in the database.

The three-layer framework is just an idea, that is, the decomposition of task responsibilities.

To put it simply, you can use three functions,

For example, fun1's task is to read the data on the interface into two numbers, and then pass the two data to fun2. no matter what fun2 does with the two data.

The task of fun2 is to subtract or add the two numbers. fun1 and fun3 do not matter (this layer is based on your specific business ).

The third fun3 task is to access the database and save a number operated by fun2 to the database.

You can use three classes to separate them.

You can build three different projects for implementation (enterprise-level architecture is like this)

The three-layer architecture is just the simplest thought of hierarchy. Some other N-layer architectures are also extended on this basis, so you must understand it well before you can smooth the learning disability in the future.

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.