Reputation: 29
Please note; Factory, not Abstract Factory.
Say, there is an interface Shape
with concrete classes like Pentagon
. Let's say an abstract class Quadrilateral
implements Shape
and has its own concrete types like Square
.
Is this still considered a Factory Method?
Upvotes: 0
Views: 783
Reputation: 17104
Firstly, the Shape
interface represents the product created by the factory. So long as the factory returns Shape
instances, any other details of the product inheritance hierarchy are irrelevant to both the factory and its clients.
Secondly, the tutorial linked in the comment describes what Head First Design Patterns calls a Simple Factory. It is not a GoF design pattern. You can read my take on the GoF patterns here.
Finally, a warning: beware any blog or tutorial using the phrase "Factory Pattern". There is no single pattern named "Factory". Factory is a category of patterns including instances both inside and outside the GoF book. There are at least four factory patterns in common use.
Upvotes: 1