Simple factory, factory, abstract factory difference

xiaoxiao2021-03-06  55

The core of the factory method model is an abstract factory class, while simple factory model puts the core in a specific class.

Simple factory is a special case of factory method model.

The most important difference between the factory method model and the abstract factory model is the extent of the factory.

The abstract factory model is generally abstract factory interface, indicating that he is a factory, regardless of it is factory factory, his abstraction is high.

The abstract factories in the factory method model are generally for products, indicating that it is a factory that produces a type of product.

The simple factory does not support inheritance. If you need to build too much, this class will make this class, and the coupling is set in this class.

The factory method solves the shortcomings that the simple factory does not support inheritance.

The object established by the above two modes is in a hierarchy.

The abstract factory is a multi-parallel level structure, and its principle of establishing an object is to divide the objects that need to be established in units of clusters (functionally similar objects).

转载请注明原文地址:https://www.9cbs.com/read-82026.html

New Post(0)