Create a schema --- factory mode

Factory Pattern

In the factory design pattern, the client can request an object, without the need to know where the objects come from, that is, which class to use to generate the object. The idea behind the plant is to simplify object creation. Compared with the client's own based on class is instantiated directly create objects based on a centralized function to implement, easier to track those objects created.

 

Plant usually has two forms: one is a factory method , which is a method (function), and returns the object to different input parameters; the second is an abstract factory , which is a set of business objects to create a series of related the factory method.

 

Factory Method

 

Guess you like

Origin www.cnblogs.com/xiaoshayu520ly/p/10978424.html
Recommended