PHP
  Home arrow PHP arrow Inheritance and Polymorphism in PHP: Building a Form Generator - Part III
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

Inheritance and Polymorphism in PHP: Building a Form Generator - Part III
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 14
    2005-04-19


    Table of Contents:
  • Inheritance and Polymorphism in PHP: Building a Form Generator - Part III
  • Turning back time: that old inefficient script
  • Polymorphism: the core definition
  • Implementing the Form Generator: take two
  • Listing full source code

  • 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


    Inheritance and Polymorphism in PHP: Building a Form Generator - Part III
    ( Page 1 of 5 )

    In the last part of this three-part series of articles, we will find out how to improve the form generator we created in part II by learning about Polymorphism and adding it to the mix.

    Introduction

    Welcome to Part III of the series "Inheritance and Polymorphism in PHP: Building a Form Generator." I hope that you had read the previous articles, Part I and Part II, so you have a good understanding of the overall concepts explained during the development of these sections.

    If you haven't read the previous articles, let's take a quick look at what we've done for now. In order to try out some of the most powerful foundations of OOP (Object Oriented Programming), we've faced the task of applying Inheritance and Polymorphism in PHP, by taking a rather practical approach and using these pillars to create a specific project: an extensible Form Generator.

    To begin with, we defined a base class named "formObject", which is the super class from which we derived all of the necessary subclasses to generate each form element, using the power of Inheritance in PHP. Once we created the proper subclasses, all we needed to do to create our working Form Generator is instantiate some objects from the subclasses -- and that's it, we have an extensible form generator!

    Well, not so fast. If we remind ourselves of the approach taken in the previous article, we'll have to admit that using a "switch" statement to determine what type of form object we're dealing with, is extremely inefficient. Our goal is to try to fix up that method and implement a much better solution. So, what's our next route to presenting a decent approximation? The answer is Polymorphism. Sounds like another buzz word, but it's really good to learn how it can be implemented in our Web projects.



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

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





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