PHP
  Home arrow PHP arrow Introducing the Lazy Loading Pattern
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

Introducing the Lazy Loading Pattern
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-09-17


    Table of Contents:
  • Introducing the Lazy Loading Pattern
  • Review: object-oriented lazy loading
  • Introducing the lazy loading pattern
  • Lazy loading 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 Lazy Loading Pattern
    ( Page 1 of 4 )

    Welcome to the third part of a five-part series on lazy and eager loading in PHP 5. In this part of the series, you'll learn about the lazy design pattern, and how to use it effectively in your applications.

    Very often, the terms "lazy" and "eager" are used in daily talking to define or qualify the way that certain people are, or simply to judge their behaviors and reactions in response to a number of situations that occur in life. The truth is that we, as individuals, are an interesting mixture of these two characteristics.

    Also, it's true that human beings try to translate these concepts to other areas, such as software programming. If you've ever developed web-based or desktop applications using your favorite compiled or interpreted language, then it's possible that you've already coded "factory" methods to create one or multiple objects, or even defined a few "Observer" and "Dispatcher" modules as well.

    Definitively, many design patterns like the ones mentioned above respond to simple translations of human behaviors within the terrain of software development, and certainly "lazy" and "eager" aren't the exception. In general, when an application uses lazy loading, it means that it delays or defers the loading of a specific resource until it's really required at runtime. On the other hand, if the same application (or a part of it) relies on eager loading, then it implies that the resource will be loaded as soon as possible, regardless of whether or not it has been requested.

    Of course, it's possible to extend the concepts of "lazy" and "eager" when working with classes, which leads to using approaches commonly known as lazy and eager instantiations respectively. In the case of PHP 5, implementing lazy and eager loading is truly a no-brainer process, and the result of this implementation can be either successful or amazingly poor, depending on the context in which these patterns are applied.

    Precisely, in the previous chapter of this series I developed an example that showed that there are times when including eagerly a class within a script can be pretty inefficient, especially if an instance of the class is created by the script in question right before it finishes its execution.

    Nonetheless, it's possible to use the benefits of lazy loading to address an issue like this very easily, and that's exactly what I'm going to show you in the lines to come. So, if the topic interests you, start reading to find out more on it!



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

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - 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...





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