HomePHP Creating AJAX Requester Objects with Abstract Factory Classes in PHP 5
Creating AJAX Requester Objects with Abstract Factory Classes in PHP 5
The abstract factory pattern can be useful if you’re developing a PHP application that needs to create diverse objects in multiple contexts. If you’re interested in learning the basics of this design pattern, this set of articles might be what you’re looking for. Welcome to the second installment of the series “Using abstract factory classes in PHP 5.” In a step-by-step guide, this series teaches you how to create abstract factory classes in PHP 5 by providing you with a wealth of educational examples on the topic.
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!