Discuz! Small nt Forum code analysis

Source: Internet
Author: User

Discuz EnabledSource codeStructure Analysis

The right figure shows discuznt (Dz) Open SourceCodeSolution Structure

The 20 projects seem to be huge. Now let's take a look at their layers. From my personal analysis perspective, discus is a typical three-tier architecture, it can be said that the architecture is relatively common,

The figure on the left shows several DZ data layer projects. The data project provides a public access interface, data. access and data. mySQL and data. sqlserver is the implementation of three data access layers for public interfaces. The number of interfaces provided by the idataprovidor interface is astonishing ..... There are nearly 5000 lines of code, and the business logic of DZ is indeed very huge. In fact, this method of writing interfaces is quite self-resisting. In this way, it seems that this implementation simply writes interfaces for interfaces, after the common access layer code is implemented, in turn, all the implemented methods are implemented as interface members of the base class. This method is correct in practice, in many cases, we tend to do this, but such 5000-line interface code is not flattering... It can be seen that the multi-database support of DZ is based on the implementation of rebuilding the access layer for each database. Fortunately, this does not affect its running performance, ^ continue analysis, discuz. data. databaseprovider provides the data layer factory method to implement multi-database support. The above is the analysis of the data access layer. It is common practice that DZ only implements interface programming in a simple way during reconstruction, no new reconstruction of the business structure;

Let's take a look at the business layer and web layer. As mentioned in the previous analysis, the common and good data factory and data access layer interfaces have been implemented, so the upper layer is completely interface-oriented, you cannot see any database access or SQL statements in these layers,

This is the web layer, which separates the background page code into an independent DLL. This is a copyright consideration, so that you cannot obtain or modify the source code, ^ this practice also makes the following web directories very lightweight. There are only a few files and directories. Generally, there will inevitably be a lot of huge web application pages to write, without full consideration, A lot of pages will be created, and in many cases, some of the pages and even the whole page are similar in functions, so we should consider using components,
DZ is an example.


The following are the DZ plug-in functions used to expand applications in subsequent development and are defined in a similar way.ProgramSet Name, according to certain specifications to write DZ Platform Plug-ins, which is now widely used,

Some websites or open-source controls provide such standards, allowing developers to add applications based on the platform, I am not clear about the specific plug-in application of DZ. I don't want to proceed with ^ mainly to analyze the general structure.

These are some common method assembly, which is not well discussed. Some Classes encapsulated in it can be used independently. It is quite convenient. discuz. cache implements the DZ cache mechanism,

The above is the source code analysis of the DZ main forum.


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.