Head First Design Patterns describes Simple Factory as
public class SimplePizzaFactory {
public Pizza createPizza(String type) {
Pizza pizza = null;
if (type.equals(“cheese”)) {
pizza = new CheesePizza();
} else if (type.equals(“pepperoni”)) {
pizza = new PepperoniPizza();
} else if (type.equals(“clam”)) {
pizza = new ClamPizza();
} else if (type.equals(“veggie”)) {
pizza = new VeggiePizza();
}
return pizza;
}
}
What are the disadvantages of Simple Factory, compared to Factory Method pattern and Abstract Factory Pattern respectively?
In Design Patterns by Gamma et al, parameterized factory methods by classes in Factory Method Pattern seem similar to Simple Factory. Is it correct that parameterized Abstract Factory would be exactly Simple Factory? Does Design Patterns mention about parameterized Abstract Factory?
Aucun commentaire:
Enregistrer un commentaire