PHP
  Home arrow PHP arrow Design Patterns in PHP - Factory Metho...
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

Design Patterns in PHP - Factory Method and Abstract Factory
By: David Fells
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 58
    2004-12-20

    Table of Contents:
  • Design Patterns in PHP - Factory Method and Abstract Factory
  • Factory Method
  • Abstract Factory
  • Drawbacks of the Example
  • Conclusion

  • 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!

    Design Patterns in PHP - Factory Method and Abstract Factory


    (Page 1 of 5 )

    Normally, in object oriented programming, object creation is not difficult. But what if your object needs to be created based on different conditions or other matters of context? Then you will spend hours in debugging and updating--unless you know about design patterns. David Fells explains how they work, and uses the creation of a maze to illustrate his points.

    Overview

    In object oriented programming, object creation - also known as instantiation - is an implied requirement. Objects must at some point be created for use. Obviously, creating objects is not a difficult task and most languages, PHP included, have simple and intuitive syntax for doing so.

    When developing larger, more complex systems though, object creation can become difficult. There are situations where different objects may need to be created based on different conditions or based on the context of the object creating it. Creating objects of concrete types explicitly in code can make these situations a nightmare when it comes time to make revisions and additions. When a new class is introduced, you get to follow a trail of code and commence the hours of debugging that will inevitably follow such an endeavor. This is where design patterns come in.

    This article will discuss the usage of Factory Method [DP107] and Abstract Factory [DP87] as they pertain to developing applications in PHP using object oriented programming techniques.

    More PHP Articles
    More By David Fells


       · I'm pretty new to Design Patterns in General. On the first page, the two described...
       · DP is a reference to the book "Design Patterns". 87 and 107 are the pages where the...
       · To be more...
       · I see, thanks! ...
       · I really enjojed this article may be you do do some more on other patterns
       · My plan is to write a series on Design Patterns in PHP but at the moment, article...
       · On page 4/5 of the article, the methods in MazeFactory class are createMaze,...
       · Great article. I gave it 5 stars.Something I'm working on right now will have a...
       · very good article. Helped me understand the difference and see the benfits of the 2...
       · this article is really useful for those who are new to design patterns.
       · Very good article, I really understood something from it.
     

       

    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 2 hosted by Hostway