PHP
  Home arrow PHP arrow Page 3 - Introducing the Facade Pattern in 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 the Facade Pattern in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2007-01-16


    Table of Contents:
  • Introducing the Facade Pattern in PHP 5
  • A basic implementation of the facade pattern
  • Using HTTP compression with PHP 5
  • Completing the facade schema
  • Seeing the facade 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 the Facade Pattern in PHP 5 - Using HTTP compression with PHP 5
    ( Page 3 of 5 )

    In consonance with the concepts that I deployed in the section that you just read, the next step that I’m going to take will consist of defining a basic facade class. This class will be capable of applying HTTP compression to any input string, in addition to removing any eventual new line characters from it.

    Having outlined the functionality of this simple facade class, please pay attention to its definition. It’s as follows:

    // define 'CompressContentFacade' class
    class CompressContentFacade{
       public static function stripContent($content){
        
    // remove new lines from content
        
    $strippedContent=StripContent::stripString($content);
         // compress content by using GZIP algorithm
         $gzippedContent=GzipContent::compressString
    ($strippedContent);
         return $gzippedContent;
       }
    }

    Despite the remarkable simplicity of the above facade class, there are a few things worth stressing about its definition. First, notice how the class in question hides all the complexity required for removing new lines characters and compressing strings behind the interface of two different classes, “StripContent” and “GzipContent” respectively.

    Second, you should realize that all of these classes are completely independent from the facade one, which means that they know nothing about the class that called them. If you recall the definition of the facade pattern, this is exactly the schema required for applying it. Now, the prior facade class should make a lot of sense to you!

    Nevertheless, I must mention that the previous “CompressContentFacade” class is indeed only half of the story when it comes to implementing the facade pattern with PHP 5, since the corresponding string compressing classes that you saw before remain undefined.

    To address this issue, in the following section I’m going to show you the respective signature for these two new classes, in this way completing the model dictated by the facade pattern.

    Do you wish to see how these classes will be created? Jump ahead and read the next few lines.



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

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





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