Data Center reconstruction-Layer 7 package diagram, reconstruction of Layer 7 Package Diagram
The typical three-tier Data Center reconstruction is changed to seven, with the appearance layer, factory layer, and IDAL layer added. The three layers added are the application of the appearance pattern in the design pattern and the abstract factory + reflection for better decoupling and. The appearance layer reduces the Coupling Degree between the U layer and the B layer. In the appearance layer, class and method of the B layer are called and combined to meet the requirements of the U layer, when the demand changes, you only need to change the appearance and B layer, or you only need to change the appearance to meet the demand changes.
The interface defined at the IDAL interface layer is implemented by the DAL layer. In the factory layer, the configuration file is used to determine the database class to which the D-layer link is instantiated, in layer B, factories and interfaces are used to call the link database of layer D. For example
There is a User interface in the IDAL layer, which includes methods for adding and Deleting Users. There are two class inheritance interfaces in layer D. One Class is linked to SQL, and the other is linked to Oracle. These two classes inherit the interface and then implement the methods.
The Factory layer contains statements for reading and writing the configuration file. It is assumed that the configuration file determines that the class to be instantiated is linked to the SQL database in layer D. To change the database, you only need to modify the keywords in the configuration file.
Abstract Factory + reflection + configuration file to prevent database replacement. The UML diagram is shown as follows:
When layer B needs to call the method of layer D, it first defines the interface and the factory. When the factory is instantiated, the factory will instantiate the interface implementation class according to the keyword of the configuration file, then it is returned to layer B. layer B is the method of the basic class called when calling the method.