dimanche 12 avril 2020

What is the difference between Factory Method and Abstract Factory in design pattern

My understanding is that Factory method like it implies in the name, it is a single method, in the coding world, it is implemented by creating an interface with a single method. If an interface contains more than 1 method, then it is an abstract factory. To make it more intuitive, the relationship between Factory Method and Abstract Method can be like

interface FactoryMethod1 { void method1(); }
interface FactoryMethod2 { void method2(); }
interface AbstractFactory extends FactoryMethod1, FactoryMethod2 {};

Is my understanding correct?

Aucun commentaire:

Enregistrer un commentaire