[Design mode] simple factory mode, design mode factory Mode
Simple Factory)It is also called the Static Factory Method mode.
The simple factory mode usually defines a factory class, which canReturn different types of product instances based on different variables.
But the simple factory Model
Does not belongOne of the 23 Gof design patterns.
Advantages
The factory class of the simple factory model is the key to the entire model. This includes the necessaryLogical judgmentDetermine the object of the specific class to be created based on the external information.
By using the simple factory mode, you do not need to know how the object is created, as long as necessary information is passed in.
Disadvantages
The factory class integrates the creation logic of all instances,ViolationHigh Cohesion responsibility allocation principle.
As the number of product categories in the system increases, it is necessary to constantly modify the factory categories, which is not easy to maintain and expand. In additionViolating the open and closed Principle
Reference: http://www.cnblogs.com/jingmoxukong/p/4250277.html