1

The main difference between a "factory method" and an "abstract factory" is that the factory method is a single method, and an abstract factory is an object. But, sometimes I can't say what it is,for example

class Product{

}
interface Facotory{
    public Product create();
}

class FactoryA implements Facotory{
public Product create() {
    return null;
}   
}

class FactoryB implements Facotory{
    public Product create() {
    return null;
    }
}

Can you tell me it is factory method or abstract factory?Thank you!

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
tomcat
  • 45
  • 1
  • 1
  • 3

1 Answers1

2

IMO, Your current example above is Factory Method.

As you have defined an interface (Factory) with a factory method (create) that allows sub classes (FactoryA and FactoryB) to decide which class to instantiate (Product derived classes).

SBirthare
  • 5,117
  • 4
  • 34
  • 59