News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DevShed:
Generating Web Pages with the Flyweight Pattern in PHP 5
March 05, 2007 @ 12:19:00

DevShed concludes their look at the Flyweight pattern with this new tutorial - the second part focusing on building an actual application with the pattern implemented.

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.

They create a simple application that generates dynamic HTML elements - DIV tags - with a simple interface to define things like content, name, and ID. Their Flyweight factory class creates and manages the number of DIVs that are created, blocking requests for any more. Finally, they apply it, showing the creation of a simple web page with multiple DIVs in it.

0 comments voice your opinion now!
tutorial flyweight designpattern html element dynamic application tutorial flyweight designpattern html element dynamic application


DevShed:
Introducing the Flyweight Pattern with PHP 5
February 26, 2007 @ 12:41:00

DevShed charges right ahead with its emphasis on design patterns in PHP with a new start of a new series today that looks at the Flyweight pattern.

Among the considerable variety of structural design patterns that can be implemented with PHP 4 (and PHP 5, by the way), there's one in particular that deserves special attention. It's easy to apply in the context of a given web application, and it offers remarkable functionality when it comes to preventing the unnecessary instantiation of different classes. This two-part series covers that pattern.

As they explain, the Flyweight pattern helps to keep your code light and simple by preventing the instantiation of unneeded objects and resources. They go with a HTML form example, illustrating how to prevent a submit button or an input button's class to be reinitialized every time a new form field is needed.

0 comments voice your opinion now!
flyweight pattern php5 designpattern tutorial form element flyweight pattern php5 designpattern tutorial form element



Community Events





Don't see your event here?
Let us know!


laravel community version release symfony podcast framework introduction voicesoftheelephpant series tool interview composer update library opinion install package security language

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework