PHP
  Home arrow PHP arrow Introducing Bridge Classes with PHP 5
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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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: 4 stars4 stars4 stars4 stars4 stars / 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:
      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 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


       · This first article of the series introduces the concept of “bridge” classes, (also...
       · Hi, what are the actual benefits of the bridge pattern compared to implementing...
       · Thank you for commenting on my PHP article. Now, with reference to your question,...
       · Bridge is used to achieve platform independence.your example IMHO doesn't qualify...
       · Many thanks for commenting on my article about the bridge pattern. Although I agree...
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





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