Just in case the abstract factory pattern doesn't ring any bells for you, let me quickly explain how it works. Basically, when this pattern is applied, there's an abstract factory class which defines what type of objects should be created by the corresponding concrete factories. On the other hand, these factories implement the required logic to make sure that the correct objects are returned to client code, according to the context where they're used. Logically, if you're anything like me, the above definition may sound rather complex. Taking this into account, in the first article of the series I explained how to use the abstract factory pattern to create different types of DIV elements, in this way showing a concrete case where this pattern can be examined in detail. Now that you hopefully have a stronger background in how this useful pattern works in PHP 5, I'm going to continue showing you more situations where abstract factory classes can be used properly. More specifically, in this second article of the series, I'm going to demonstrate how to apply the abstract factory pattern to create diverse AJAX HTTP requester objects, which can be used in distinct contexts. I'm pretty certain that once you read this tutorial, you'll have a more accurate idea of how to apply this handy pattern in your own PHP applications. Having already defined the subject of this article, let's find out together how to use an abstract factory class to create AJAX HTTP requester objects. Let's begin now!
blog comments powered by Disqus |