Understand the ease of migrating petshop4.0 to a simplified architecture Database

Source: Internet
Author: User

Previously, the company had been using petshop4.0 to streamline the architecture, but the amount of code is relatively large. If you want to change a method parameter, the interface layer, database layer, and logic layer must be closely associated with the change.
But I cannot see the benefits of doing so. I can use the most common Layer 3 (Data + logic + representation). Why must I add an interface and a factory layer?
It can be divided into several layers:

Msoft. Mat .................................... Website
Msoft. Mat. BLL .............................. Logic
Msoft. Mat. dalfactory ..................... Factory reflection
Msoft. Mat. idal .............................. Interface
Msoft. Mat. sqlserverdal .................. Data
Msoft. Mat. dbutility ..................... Database Connection
Msoft. Mat. Model .............................. Entity

The most common Layer 3 is probably the interface and factory layer, because these two layers bring convenience to database transplantation.
For example, if the SQL serser database is used and the database needs to be migrated to the Oracle database, the database layer has an additional layer (as shown below ):

Msoft. Mat .................................... Website
Msoft. Mat. BLL .............................. Logic
Msoft. Mat. dalfactory ..................... Factory reflection
Msoft. Mat. idal .............................. Interface
Msoft. Mat. sqlserverdal .................. Data (SQL)
Msoft. Mat. oracledal .................. Data (Oracle)
Msoft. Mat. dbutility ..................... Database Connection
Msoft. Mat. Model .............................. Entity

 

 
Because the Assembly name called by factory reflection is dynamic configuration (generally on the web. config configuration), that is, msoft. mat. sqlserverda and msoft. mat. oracledal is dynamic, and the name of the class to be instantiated is the same as that of the interface. Therefore, you only need to modify the database layer for database transplantation to achieve the effect (of course, the database connection string also needs to be changed)
When we have done a good job in various data layer classes, for example, we plan to port data between sqlserver, Oracle, and MySQL databases, we can define the data class as follows:

Msoft. Mat .................................... Website
Msoft. Mat. BLL .............................. Logic
Msoft. Mat. dalfactory ..................... Factory reflection
Msoft. Mat. idal .............................. Interface
Msoft. Mat. sqlserverdal .................. Data (SQL)
Msoft. Mat. oracledal .................. Data (Oracle)
Msoft. Mat. mysqldal .................. Data (MySQL)
Msoft. Mat. dbutility ..................... Database Connection
Msoft. Mat. Model .............................. Entity

Modify the Assembly name variable in the configuration file (for example, to port to the Oracle database, the variable = "msoft. Mat. oracledal" in webconfig) to achieve database migration.
This is just my own understanding. If something is wrong, I hope you can correct it.

Well, write it here first. I want to resign now! Maybe this is the last few technical blogs. I don't know if I have the chance to write more DOTNET technical blogs 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.