工厂模式和抽象工厂模式的基本区别是什么?[英] What is the basic difference between the Factory and Abstract Factory Patterns?

本文是小编为大家收集整理的关于工厂模式和抽象工厂模式的基本区别是什么?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

工厂模式和抽象工厂模式的基本区别是什么?

推荐答案

使用工厂模式,您可以生成特定接口的实现(Apple、Banana、Cherry 等)——例如,IFruit.

使用抽象工厂模式,您可以生成特定工厂接口的实现——例如,IFruitFactory.他们每个人都知道如何制作不同种类的水果.

本文地址:https://www.itbaoku.cn/post/627476.html

问题描述

What is the basic difference between the Factory and Abstract Factory Patterns?

推荐答案

With the Factory pattern, you produce implementations (Apple, Banana, Cherry, etc.) of a particular interface -- say, IFruit.

With the Abstract Factory pattern, you produce implementations of a particular Factory interface -- e.g., IFruitFactory. Each of those knows how to create different kinds of fruit.