PHP
  Home arrow PHP arrow Implementing the Stage 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? 
Google.com  
PHP

Implementing the Stage Pattern in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2007-04-18


    Table of Contents:
  • Implementing the Stage Pattern in PHP 5
  • Creating the programmatic model of the state pattern
  • Changing the behavior of a target class
  • Seeing the stage 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


    Implementing the Stage Pattern in PHP 5
    ( Page 1 of 4 )

    Updating modules of a web application can be quite a chore, especially when classes are involved. Wouldn't it be easier if there were a class that could update itself depending on its context? Fortunately there is. It's called the Stage pattern. This is the first part of a two-part series that introduces you to that pattern and its uses.

    Introduction

    It’s quite probable that during your life as a PHP developer, you have found yourself updating specific modules of a given web application (or in the worst case, the entire application), since the context where it was originally conceived to work has changed noticeably.

    Naturally, if this situation sounds familiar to you, then you’ll know that updating certain parts of an application can be an annoying, time-consuming process. it can be even worse if you have to deal with other issues apart from the ones related to coding, such as suiting deadlines, solving “creative” differences between members of the same development team, and so forth.

    Thus, considering all the possible problems that can emerge when a particular PHP application must be updated, you try to write code that is highly maintainable and easy to update. However, if I translate the aforementioned scenario to the terrain of object-oriented programming, sometimes it happens that one or more PHP classes need to be updated according to the modifications introduced into the context where they were initially designed to work.

    From a developer’s point of view, this updating process can be difficult, particularly if the application that needs to be modified is comprised of a considerable number of interrelated classes. Therefore, the question that comes up here is: is there any programmatic mechanism that allows you to create a class that changes the way it works, according to the variations incorporated into its environment?

    Fortunately, the answer to the previous question is an emphatic yes! In the huge area of pattern-based programming, there’s one pattern called “Stage” that provides developers with a handy mechanism for building a class that’s capable of modifying its behavior in response to the changes introduced into its environment. Indeed, this sounds pretty interesting, right?

    Nevertheless, at least at first glance, the definition of the “Stage” pattern seems hard to grasp, which implies that the pattern in question has to be addressed from a practical point of view. In doing so, you’ll have a much better idea of how it works, and eventually how it can be applied in concrete cases.

    Therefore, assuming that the stage pattern has already caught your attention, over the course of this two-part series, I’m going to introduce its key concepts, and logically show you how to implement it with copious code samples.

    At the end of this series, you should be equipped with a decent background in how to include the stage pattern in your own PHP applications, aside from expanding your overall skills in pattern-based programming. So, are you ready to dive deeper into the implementation of this handy pattern? Let’s begin now!



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

       

    PHP ARTICLES

    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - 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





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek