SunQuest
 
       PHP
  Home arrow PHP arrow The Basics of Using the Factory Patter...
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 
VeriSign Whitepapers 
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

The Basics of Using the Factory Pattern in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2007-06-25

    Table of Contents:
  • The Basics of Using the Factory Pattern in PHP 5
  • Developing some basic factory classes
  • Defining some array processing classes
  • Testing the functionality of the factory pattern

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    The Basics of Using the Factory Pattern in PHP 5


    (Page 1 of 4 )

    If you need to create multiple objects that belong to the same family, you probably want to use the factory pattern. This three-part series takes a close look at using the factory pattern in PHP.

    Introduction

    Many PHP developers with a solid background in pattern-based programming know that there are certain patterns that are more difficult to grasp than others. This is due mostly to the inherent diversity of this fascinating terrain, where purist concepts about software design merge flawlessly with simple, natural common sense.

    Indeed, design patterns present singularly interesting facets. They are conceived as proven solutions to specific programming-related issues, but at the same time, have a certain dose of improvisation, which makes them even more attractive. Logically, if you think carefully about this concept, you'll understand more clearly the meaning of this question: how many times did you find yourself applying a particular pattern without knowing what you were actually doing? Perhaps dozens, even hundreds of times.

    Nevertheless, the most important thing to notice here is that a concrete problem can be solved by implementing the logic of a particular pattern, which means that certain software development issues can be addressed in a more intuitive way than others. And definitely, the factory pattern is an excellent example of this situation, since many developers use it frequently, even if they're taking their first steps into the object-oriented programming arena.

    Admittedly, it's common to see during the development of a given PHP application that one or more classes are created with the purpose of returning a specific type of object to client code, where the object must conform to the specifications of a concrete environment. As you may have guessed, this is precisely the theoretical definition of the factory pattern.

    Summarizing, the factory pattern can be really useful when it comes to creating multiple objects that belong to the same family. In this three-part series I'm going to take a close look at it, and also demonstrate its remarkable functionality by showing you a decent variety of code samples, so you can start quickly including this pattern into your own PHP applications.

    With the preliminaries out of the way, now let's move on together and begin discovering how to apply the factory pattern with PHP. It's going to be an educational journey, believe me!

    More PHP Articles
    More By Alejandro Gervasio


       · Indeed, in the terrain of pattern-based programming, certainly the factory pattern...
     

       

    PHP ARTICLES

    - 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...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





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