简体   繁体   中英

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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