简体   繁体   English

目标c中的工厂设计模式与工厂方法设计模式和抽象工厂之间有什么区别?

[英]What is the difference between Factory design pattern from Factory method design pattern and abstract factory in objective c?

The more I search the more confused I become. 搜索的次数越多,我就会变得更加困惑。 Is the factory design pattern the superclass of Abstract factory and factory method? 工厂设计模式是抽象工厂和工厂方法的超类吗? Or it is the other name for static factory? 还是静态工厂的别称?

So to reduce confusion: 因此,为了减少混乱:

Factory Method and Abstract Factory are two different uniquely named design patterns. 工厂方法和抽象工厂是两种不同的唯一命名的设计模式。 Unique names are important to identify them from the other. 唯一名称对于彼此区分很重要。 Both of them belong to the object creational design patterns category (or class). 它们都属于对象创建设计模式类别(或类)。 While being creational design patterns, they are solutions to very different object creation related problems. 它们是创新的设计模式,是解决与对象创建相关的问题的解决方案。

The names "factory design pattern" or "static factory" are not commonly used to indicate unique design patterns. 名称“工厂设计模式”或“静态工厂”通常不用于表示独特的设计模式。 Generally, the term "factory" is used to refer to anything that creates objects (So you may talk about a factory class, factory object, factory method and so on but know clearly that there's a unique design pattern with the name "factory method" as well). 通常,“工厂”一词用于指代创建对象的任何事物(因此,您可以谈论工厂类,工厂对象,工厂方法等,但要清楚地知道有一种独特的设计模式,名称为“工厂方法”。以及)。

Also, the term "static factory" may openly be used to talk about a class with a static method that has an object creational responsibility even though a widely accepted unique pattern does not exist with that name. 同样,术语“静态工厂”可以公开地用于谈论具有对象创建责任的静态方法的类,即使该名称不存在被广泛接受的唯一模式。

There's no authority that assigns names to design patterns. 没有权限将名称分配给设计模式。 It's only that some design patterns become popular and then their names are popularly used to reference them. 只是有些设计模式变得流行,然后它们的名称才被普遍用来引用它们。

Design patterns that do not gain popularity may still use names but others may unknowingly use the same names to refer to different things. 不流行的设计模式可能仍然使用名称,但其他设计模式可能在不知不觉中使用相同的名称来指代不同的事物。 So the names "factory design pattern" and "static factory" are still open for the public to use as they prefer until someone registers them as trade marks :) 因此,“工厂设计模式”和“静态工厂”这两个名称仍然可以向公众开放,直到有人将其注册为商标为止:)

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

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