简体   繁体   English

工厂方法模式和抽象工厂模式

[英]Factory method pattern and abstract factory pattern

I have a question which has been explained in many ways , but still has not made me clear. 我有一个问题已经用多种方式解释了,但仍然没有使我明白。

  1. What is creating of objects by "Object composition" in terms of abstract factory pattern ? 用抽象工厂模式用“对象组合”创建对象是什么?

It seems like both the patterns use inheritance to create objects. 似乎这两种模式都使用继承来创建对象。

Object composition means the object is composed of something. 对象组成是指对象由某物组成。 It's basically the strategy pattern, making the two objects have a "has-a" relationship, rather than an "is-a" relationship (as with straight inheritance). 基本上,这是一种策略模式,使两个对象具有“具有”关系,而不是“具有”关系(如直接继承一样)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM