Reputation: 25
I am reading a book named Head First Design Patterns. I am confused about Abstract Factory Pattern. It is said that Abstract Factory provides an interface for creating families of related or dependent objects without specifying their concrete classes. This is also a point that makes it different with Factory Method.The authors give an example of NYPizzaIngredientFactory, which is a concrete subclass that can create a family of products by calling some methods within the class (such as createDough(), createSauce()). However, I would think that in order to create a specfic Sauce, the class have to rely on concrete classes such as, PlumTomato Sauce or Marirana Sauce. It means that Abstract Factory have to specify concrete classes for these objects. Do I think that right? Please help. Thanks!
Upvotes: 0
Views: 168
Reputation: 41542
Well, the abstract factory itself doesn't have to specify any concrete classes, because it's abstract -- it has no implementation code.
The implementations of the abstract factory do, of course. but:
Sauce
, then you are guaranteed to receive something which can be used as a Sauce
.Upvotes: 2