PHP
  Home arrow PHP arrow Page 4 - Handling File Data with the Facade Pat...
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

Handling File Data with the Facade Pattern in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2007-01-23

    Table of Contents:
  • Handling File Data with the Facade Pattern in PHP 5
  • Using the facade pattern to handle file data
  • Applying the facade pattern to a string processor
  • Putting all the classes to work together

  • 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


    Handling File Data with the Facade Pattern in PHP 5 - Putting all the classes to work together


    (Page 4 of 4 )

    In this final section of the article, I’d like to show you how all the classes that I created previously can be put to work conjunctly. In this manner I'll demonstrate the neat functionality offered by the already familiar facade pattern.

    Below I set up a short example. It shows the output generated by the pertinent file processing class, and the different results displayed by the respective facade class.

    Having said that, here the complete source code that corresponds to the hands-on example in question:

    // example using 'ProcessContentFacade' class
    try{
       // instantiate new 'FileProcessor' object
       $fileProc=new FileProcessor();
       // write data to file
       $fileProc->writeData();
       // read and display file data before using 
       // 'ProcessContentFacade' class
       echo $fileProc->readData();
       /*
       displays the following:
       This string of data will be saved to file!
       */
       // reverse and uppercase file data by using
       // 'ProcessContentFacade' class
       $processedData=ProcessContentFacade::
    processContent($fileProc->readData());
       echo $processedData;
       /* displays the following:
       !ELIF OT DEVAS EB LLIW ATAD FO GNIRTS SIHT
       */
    }
    catch(Exception $e){
       echo $e->getMessage();
       exit();
    }

    Without a doubt, after studying the above example, you’ll realize that implementing the facade pattern with PHP 5 is indeed a straightforward process that can be performed with only minor troubles. As usual, feel free to incorporate your own modifications to all the classes that were shown in this article. Doing so will help you acquire a more intimate grounding in how this design pattern works. Happy coding!

    Final thoughts

    Sadly, this is the end of this series. Over the course of these two tutorials, I introduced the fundamentals of how to apply the facade pattern in PHP 5. If you spend some time and practice with the examples that I provided you here, I’m pretty certain that you’ll end up having a reasonable experience on this pattern in particular.

    See you in the next PHP tutorial!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · In this final article of the series, another example on how to implement the facade...
     

       

    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 4 hosted by Hostway
    Stay green...Green IT