Blog from Kenny background
When opening a portal website, we often see many closely arranged channels, such as "news", "finance", and "Entertainment. Channels provide convenient navigation for websites.
Knowledge preparation
The architecture schemes mentioned in this article are based on the Model-View-Controller mode. The components in this mode are briefly described as follows:
◆ Model: includes business logic operations and data access operations
◆ View: Contains operations related to UI processing.
◆ Controller: controls and coordinates the process of View and Model processing.
Comparison of various solutions
Solution |
Architecture Description |
Code reusability |
Development Method |
Deployment Method |
Solution 1 |
Create a Web Project for the entire website. Each channel corresponds to a directory in the Web Project, which is somewhat similar to the ASP processing method. The Model component can be included in a Web Project or encapsulated into a Class Library. |
After the Model component is encapsulated into a Class Library, high reusability will be achieved. |
Modules are concentrated and quick to develop, but they are not suitable for large-scale collaborative development. |
Modules are concentrated and easy to deploy, but a small BUG may paralyze the entire website. |
Solution 2 |
Create a Web Project for each channel. The Model component of each channel can be included in the corresponding Web Project or encapsulated into the Class Library respectively. |
Each Model component is applied to a specific channel, with scattered code and low reusability. |
Each module is relatively independent and is suitable for assigning tasks based on function modules. |
The modules are independent and the deployment work is complicated. However, because the channels are loosely coupled (or even can be located on different servers), the failure of one channel does not affect the normal operation of other channels. |
Solution 3 |
Create a Web Project for each channel. The Model components of all channels are encapsulated into a shared Class Library. |
All channels share a Model component, with concentrated code and high reusability. |
The development method is flexible. You can assign tasks by function module or by components of MVC. |
The modules are independent and the deployment work is complicated. However, because the channels are loosely coupled (or even on different servers), failure of one channel does not affect the normal operation of other channels. |
Summary
Based on the above analysis, we can draw the following conclusions:
Solution 1: Quick Development and convenient deployment, suitable for small websites with simple business functions;
Solution 2: many defects are not recommended;
Solution 3: The modules are loosely coupled and the code is reusable. It is suitable for large-scale collaborative development and is suitable for large and medium-sized websites with complex business functions.
About Model Parts
The Model component encapsulates all business logic operations and data access operations, which may include object entity classes, object operation classes, and data entity classes. In addition, I strongly recommend that small and medium-sized application systems combine object entity classes, object operation classes, and data entity classes into a business logic class, which can greatly improve the development and maintenance efficiency.
The following describes the specific implementation methods of the third solution. First, let's look at the main architecture of the solution.
Main Architecture
Each channel is located in a different Web Project (with an independent second-level domain name), and all business logic and data access functions are encapsulated into a Class Library. All channels share this Class Library. As shown in:
|
Multi-channel website subject Architecture |
The implementation method is described in detail below.
Assume that the website has three channels: news, forums, and blogs. The corresponding second-level domain names are "news", "forum", and "blog ". In addition, two domain names need to be defined for the website homepage and user registration and login functions (based on the Passport mechanism, this article will be detailed later ), the corresponding domain names are "homepage" and "passport ".