What are the differences between Abstract Factory and Factory design patterns?

后端 未结 17 1522
醉话见心
醉话见心 2020-11-22 01:57

I know there are many posts out there about the differences between these two patterns, but there are a few things that I cannot find.

From what I have been reading,

17条回答
  •  庸人自扰
    2020-11-22 02:38

    Factory Method relies on inheritance: Object creation is delegated to subclasses, which implement the factory method to create objects.

    Abstract Factory relies on object composition: object creation is implemented in methods exposed in the factory interface.

    High level diagram of Factory and Abstract factory pattern,

    diagram

    For more information about the Factory method, refer this article.

    For more information about Abstract factory method, refer this article.

提交回复
热议问题