PHP
  Home arrow PHP arrow Building a Data Validation System with the Prototype Pattern with PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building a Data Validation System with the Prototype Pattern with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 9
    2007-05-22


    Table of Contents:
  • Building a Data Validation System with the Prototype Pattern with PHP 5
  • Building a simple data validation system
  • Creating a few additional classes
  • Creating an example

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building a Data Validation System with the Prototype Pattern with PHP 5
    ( Page 1 of 4 )

    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.

    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
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT