Home arrow PHP arrow Generating Web Pages with the Flyweight Pattern in PHP 5

Generating Web Pages with the Flyweight Pattern in PHP 5

Unnecessary and balanced instantiation of PHP classes are issues that can be easily solved by using the flyweight design pattern. If you want to learn more about it, you should start reading this article. Welcome to the final part of the series “Using the flyweight pattern with PHP 5.” As you may have guessed, this series walks you through the implementation of this helpful pattern with PHP, and shows you how to apply it in concrete cases.

  1. Generating Web Pages with the Flyweight Pattern in PHP 5
  2. Building dynamic web page elements
  3. Defining a flyweight factory class
  4. Putting the flyweight factory class to work
By: Alejandro Gervasio
Rating: starstarstarstarstar / 6
March 05, 2007

print this article




If you've been a patient reader and already went through the first part of this series, then you'll know what the flyweight pattern is about. However, if that's not the case, let me offer you a quick introduction to it so you can grasp more easily the set of examples that I plan to include in this article.

Essentially, when the flyweight design pattern is applied, there's one class that controls programmatically the number of objects created across a given application. This implies that the pattern can be used to avoid the unnecessary instantiation of a particular class, and to introduce an improvement in the web server on which the application is running.

Of course, this definition may sound a bit confusing at first, since the implementation of flyweight classes requires some practice. It's certainly a concept that can be applied to different topics on pattern-based PHP programming as well.

Nonetheless, you shouldn't feel intimidated by the potential complexity of the subject. In this final part of the series, I'm going to teach you in a step-by-step format how to create in PHP 5 a flyweight class to balance the instantiation of objects that will be used to generate web documents on the fly. Hopefully, by the end of this article, you should have acquired a considerable background in how to apply the flyweight pattern in a real-world situation.

With the preliminaries out of the way, let's continue learning more about how to create flyweight classes with PHP 5. Let's go!

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: