HomePHP Centralizing the Validation of Data with the Observer Pattern in PHP
Centralizing the Validation of Data with the Observer Pattern in PHP
Are you looking for an easygoing article that teaches you how to implement the Observer design pattern inside your PHP 5 applications? Your search is finished! Welcome to the last part of the series "The Observer Pattern in PHP." Made up of three articles, this series will show you how to create and work with observer objects, without making you scratch your head while looking at complex code samples.
For those of you who didn't (yet) read the previous installment of this series, let me explain quickly the topics it covered. To begin with, I gave an accessible explanation of what the Observer pattern is about, and accompanied all the corresponding theory with a straightforward practical example, to help you easily understand how to apply this popular design pattern in your own PHP 5 applications. I'm don't mean to say that you're going to grasp the logic of observer objects in no time, but I firmly believe that a simple example will help you out by pointing you in the right direction.
Provided that you already know what an observer object is, you'll realize that this pattern is indeed helpful for decoupling disparate objects from the rest of the application. Besides, the pattern will assist you in the development of programming mechanisms aimed at reflecting specific changes produced by several components at the application's core level. This is a highly desired feature, particularly if you're building PHP programs that require the implementation of truly independent objects.
Right, I hope the concepts that I touched on above are fresh in your mind now, because it's time to continue exploring the advantages of using the Observer pattern in PHP 5. Now, surely you're wondering: how does this story continue? Well, over the course of this last tutorial, I'll be moving the application of observer objects toward the real world, in this case by showing you how to include these objects within a set of form-validation classes. After reading this article, you should be equipped with a decent knowledge of how a form checking application can use the powerful features of this widely-known design pattern.
Having established the goals for this last installment of the series, it's time to continue learning about observer objects. Let's do it together!