PHP
  Home arrow PHP arrow Introducing the Composite Pattern in P...
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 
Moblin 
JMSL Numerical Library 
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

Introducing the Composite Pattern in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-03-07

    Table of Contents:
  • Introducing the Composite Pattern in PHP 5
  • Introducing the basics of the composite pattern
  • Implementing the composite pattern's model
  • Seeing the composite pattern in action

  • 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


    Introducing the Composite Pattern in PHP 5


    (Page 1 of 4 )

    The composite pattern is one of the less commonly used patterns in PHP 5. Nevertheless, in certain situations, it is very helpful. This article, the first one in a two-part series, will introduce you to the basic concepts of the composite pattern.

    Introduction

    In the vast and definitely fascinating terrain of pattern-based application development with PHP, quite possibly you'll know that there are certain patterns that are much simpler to implement than others. Actually this fact is a logical consequence of having acquired a strong background in the most common ones.

    It's highly probably that you already have a solid knowledge of some familiar topics that belong specifically to software engineering, such as what a Singleton is, or how a concrete factory class can be created with PHP by a few easy steps.

    However, while there are specific design patterns that are indeed used by many developers on a frequent basis during the development of different PHP applications, the truth is that there's a small group of them that very often remain unexplored, either because they simply can't be applied so quickly in real world situations, or because of their rather complex implementation.

    So, considering the fact that this limited set of uncommon design patterns can be potentially interesting to you (and to me, by the way), and taking into account that they do deserve at least a quick look, in this two part series I'm going to teach you how to implement the composite pattern with PHP 5.

    Just in case this pattern doesn't ring any bells to you, let offer you a quick introduction to how it works. In crude terms, when the composite pattern is applied in the context of a given application, one single object or a group of these objects will expose a nearly identical behavior. In other words, this means simply that it's possible to build a class in such a way that it will be capable of returning to client code the same output, regardless of whether the class in question works with one or with multiple objects. Sounds really interesting, isn't it?

    Naturally, in this case I'm aware of the high level of abstraction that the composite pattern intrinsically possesses, therefore over the course of these two tutorials, I'm going to demonstrate how this pattern works by setting up numerous code samples, which surely will help understand the topic more clearly.

    Having introduced quickly a basic definition on the composite pattern, let's move on and see how it can be implemented in PHP 5. The journey is going to be really educational, trust me, so let begin right now!

    More PHP Articles
    More By Alejandro Gervasio


       · In this first isntallment of the series, you'll learn the key concepts on the...
     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





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