PHP
  Home arrow PHP arrow Introducing Bridge Classes with PHP 5
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

Introducing Bridge Classes with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2007-01-03


    Table of Contents:
  • Introducing Bridge Classes with PHP 5
  • Introducing the basics of the bridge pattern
  • Implementing the bridge pattern’s core logic
  • Implementing the logic of a bridge class in a different hierarchy level
  • Seeing the bridge pattern in action

  • 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


    Introducing Bridge Classes with PHP 5
    ( Page 1 of 5 )

    The bridge class, or what's commonly known as the bridge pattern, lets you create a class with its abstract functionality and implementation residing on different class hierarchies. This lets you decouple the class from its concrete application. This article, the first of three parts, introduces you to the bridge pattern and its uses.

    Introduction

    If you’re a PHP developer who has a significant background in developing object-based applications, then possibly you’ll agree with me that when it comes to implementing an approach for decoupling the logic of a given class from its concrete implementation, there are some trusted techniques that can be applied successfully.

    Among others, the factory pattern is one of the cases that best applies the concept that I described above. When this pattern is used, it’s possible to create a class that simply “returns” objects to calling code, without having to worry about how these objects behave inside the context of a given application or even how long they persist during the request of multiple PHP files.

    However, and now speaking more specifically, using a factory class inside an application implies that you can decouple the logic that stands behind all the created objects from the corresponding creator. At the same time, this means that multiple objects (at least two) are involved in the creation process. Without a doubt, the situation that I illustrated a few lines ago should bring up the following question: is it feasible to work with only one class (not many classes) that can be decoupled from its concrete implementation?

    Fortunately, the answer to the above inquiry is a loud "Yes!" To give you an example covering the topic in question, think about an abstract class, where its implementation is most of the time separated from its declaration. That sounds really good, and indeed the application of abstract classes is an important link in the chain of object-oriented programming, but definitely it’s not the only approach used for separating a class from its implementation.

    Assuming that you’re interested in learning an alternative approach for achieving the mentioned decoupling process, let me now introduce the concept of “bridge” classes, or what’s more generally known as the bridge pattern. In this specific case, it’s possible to create a class where its respective abstract functionality and implementation reside on different class hierarchies, in this way allowing you to decouple the class in question from its concrete application. And best of all, the referenced procedure can be performed without using abstract classes at all.

    Of course, I’m pretty certain that all this theory on applying the bridge pattern seems to be a hard thing to grasp, but in fact it’s much simpler than you think. Thus, in this series, which is comprised of three tutorials, I’m going to teach you how to create and use bridge classes with PHP 5, by showing you numerous hands-on examples that can be easily included in your own PHP applications with minor modifications.

    Ready to learn more on how to apply the bridge design pattern with PHP? All right, let’s no waste more time in preliminaries and begin now!



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

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





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