Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Design pattern-- summary of factory pattern

Shulou Source: shulou.com Published: 2022-06-03 07:55:45 10月02日 Update

In the design pattern, the factory pattern can also be subdivided into simple factory pattern, factory method pattern and abstract factory pattern. In the past, the concepts of these three design patterns were not very clear, so here is a summary:

1. Simple factory model

An abstract product derives multiple concrete products; users can create specific products according to some properties of the product according to a specific factory. Factories and specific products are one-to-many.

two。 Factory method model

An abstract product derives from a specific product; an abstract factory derives from a specific factory; and the user creates a concrete product based on the specific factory. Specific factories and specific products are one-to-one.

3. Abstract factory pattern

An abstract product derives from a specific product; an abstract factory derives from a specific factory; and the user creates a concrete product based on the specific factory and some attributes of the product. Abstract factory patterns can be seen as a combination of simple factory patterns and factory method patterns!

Follow-up to the code sample!

Tags: Factory pattern product method user design pattern design property clear one-to-one code multiple concept example combination subdivision Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Shulou Technology Shulou Information Redmi