Home arrow PHP arrow Decoupling the Validation of Data with Bridge Classes in PHP 5

Decoupling the Validation of Data with Bridge Classes in PHP 5

Are you interested in expanding your existing knowledge of different structural design patterns with PHP 5? Then look no further because you’ve come to the right place. Welcome to the second installment of the series “Using Bridge Classes with PHP 5.” This group of three articles walks you through the basics of how to apply the bridge pattern in PHP-based applications, and it also teaches you how to use bridge objects in real world development environments.

TABLE OF CONTENTS:
  1. Decoupling the Validation of Data with Bridge Classes in PHP 5
  2. Building a bridge validator class
  3. Defining a set of bridged classes
  4. Putting all the classes to work
By: Alejandro Gervasio
Rating: starstarstarstarstar / 4
January 10, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Provided that you already went through the first tutorial of the series, and learned how to create bridge classes with PHP 5, then I’ll assume that the logic that drives the mentioned pattern is quite familiar to you. However, if you’re taking the first steps on this topic, let me give you a brief introduction to how this pattern works, thus the upcoming examples that I plan to include in this article will be much easier to understand.

Essentially, in the bridge design pattern, a specific class and its respective implementation reside on different class hierarchies, which is accomplished without using an abstract class. As you’ll possibly imagine, this model is very convenient for decoupling the generic structure of the class in question from its concrete definition, since the corresponding implementation is achieved by one or more “bridged” classes.

To clarify the previous definition, in the preceding article I developed a concrete example in which a bridge class behaved as an intermediate entity for saving a target object to different storage locations. Even when this example didn’t have an immediate application in real situations, it was really useful for demonstrating how the bridge pattern can be applied in PHP 5.

However, this instructive journey has just started. In the course of this second tutorial, I’m going to show you how to create a bridge class which will come in handy for decoupling the validation of user-supplied data. There will be a class that defines generically how certain data must be verified, while others will implement different validation methods.

Having explained what this article is about, let’s go ahead and continue learning more about this powerful pattern. Let’s go!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: