PHP
  Home arrow PHP arrow Using the Memento Pattern with a File ...
Dev Shed Forums 
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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

Using the Memento Pattern with a File Reading Class
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2007-01-15

    Table of Contents:
  • Using the Memento Pattern with a File Reading Class
  • Building an originator class
  • Defining the signature of a caretaker class
  • The memento design 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


    Using the Memento Pattern with a File Reading Class


    (Page 1 of 4 )

    The memento pattern can be used to maintain the state of a property that belongs to a specific class. If you want to learn more about how to do this, start reading this tutorial! Welcome to the final installment of the series "Maintaining the State of Classes." In two parts, this series teaches you how to use the memento design pattern with PHP 5, and it accompanies the corresponding theoretical concepts with diverse hands-on examples.

    Introduction

    If you already read the first article of the series, then you'll surely recall what this pattern is about. Just in case the subject doesn't ring any bells to you, however, let me offer you a quick introduction. In short, when the memento pattern is applied, two classes are required to satisfy a well-defined model: the "originator" and the "caretaker." 

    Where this pattern is used, the caretaker is capable of holding the value of one or more properties that belong to the respective originator. Nevertheless, a classic implementation of these two classes means usually that the referenced caretaker can't directly access the properties of the originator. So how can its state be maintained? Usually the caretaker takes the originator as an input parameter, and uses all its methods to gain access to the respective properties.

    All right, I think that the previous explanation should give you an accurate idea of how this pattern works. Let me now introduce the topics that I'll be covering in this last article of the series. I'll show you how to use the memento pattern to keep track of some properties that correspond to a file reading class. In this way we'll construct a flexible mechanism for moving back and forth between file lines.

    With the preliminaries out of our way, let's continue exploring the capacities offered by the memento pattern. Let's get started!

    More PHP Articles
    More By Alejandro Gervasio


       · Over this final article of the series, you'll learn how to use the memento pattern...
     

       

    PHP ARTICLES

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway