With more on the PHP patterns front, Devshed has a new article posted about the Factory Method and Abstract Factory.
This article will discuss the usage of Factory Method [DP107] and Abstract Factory [DP87] as they pertain to developing applications in PHP using object oriented programming techniques.
The first pattern used to simplify object instantiation is the Factory Method pattern. The Factory Method pattern defines an interface for object creation but defers the actual instantiation to subclasses. Take, for example, an application that processes Electronic Funds Transfers (ETFs). There are numerous types of ETFs including virtual check, credit card, wire transfer and so on. Using a non-pattern based approach, the application code requesting an ETF object would need to know precisely what subclass of ETF is needed, and it would need to know the context in which that type of ETF is requested.
They continue on, giving several code examples as well as illustrating the creation of an Abstract Factory.
The Factory pattern, to me, seems a little redundant. Yes, I can see the use in creating a "default function" and a sort of template for other child classes to use, but I'd much rather just have the functionality there and not need the extra overhead of including a mostly empty class...




