PHP
  Home arrow PHP arrow Building a Data Validation System with...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
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: 4 stars4 stars4 stars4 stars4 stars / 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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    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


       · This last article of the series goes through the development of a data validation...
       · First I want to say that I enjoy reading your articles. They are clearly written...
       · Firstly, I’d like to say I’m glad you find my PHP articles useful, so I thank you...
     

       

    PHP ARTICLES

    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway