Home arrow PHP arrow Building a Data Validation System with the Prototype Pattern with PHP 5

Building a Data Validation System with the Prototype Pattern with PHP 5

It's unusual to create multiple instances of a class, but certainly it may happen during the development of a PHP application. To solve this issue quickly and with minor hassles, the prototype design pattern can be really useful. If you want to learn more about it, this article might be what you need.

TABLE OF CONTENTS:
  1. Building a Data Validation System with the Prototype Pattern with PHP 5
  2. Building a simple data validation system
  3. Creating a few additional classes
  4. Creating an example
By: Alejandro Gervasio
Rating: starstarstarstarstar / 9
May 22, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Welcome to the final part of the series  that began with "The Basics of Using the Prototype Pattern with PHP 5." Comprised of two articles, this series shows you how to work with many instances of a given class using the remarkable functionality provided by the prototype pattern. It complements the theoretical concepts with a certain number of hands-on examples.

If you read the preceding article of the series, you're already familiar with the logic that drives the prototype pattern, since its implementation is extremely simple. Otherwise, if this pattern doesn't ring any bells for you, let me give you a brief explanation of how it functions.

Essentially, when the prototype pattern is applied in the context of a given PHP application, there's a class not surprisingly called "prototype" too, which is the original model followed by all the objects created from it. However, while this feature is common to all the conventional classes, the most interesting aspect of this pattern is that the first object created from the originating class is used to clone other objects, in this way giving us multiple instances of it.

As you can see, the prototype pattern has a rather uncommon implementation. That characteristic is precisely what makes it interesting from a developer's point of view, aside from its remarkable capacity for working with multiple instances of the same class.

Therefore, taking into account that this pattern can be helpful in situations where a prototype object is required, along with other clones of it, in this final installment of the series I'm going to demonstrate how to use it to build a simple application for checking the validity of incoming data.

I think you'll find this exercise to be both interesting and fun. So, come with me and let's learn together how to implement the prototype pattern in a more useful fashion. Let's begin now!



 
 
>>> 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: