News Feed
Sections




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

PHPBuilder.com:
Using the Factory Pattern in PHP Applications
February 25, 2011 @ 10:07:37

On PHPBuilder.com today, there's a new tutorial posted about using one of the more well-known design patterns in your PHP applications - the Factory Pattern. Design patterns are repeatable methods for doing common tasks in a "best practices" sort of way.

In this article you will learn how to use the factory pattern design in your PHP application to construct different objects for interrogating a database (books) and displaying the records from a table (bookstore) [...] The essence of the factory method pattern is to "define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses."

He illustrates with a few sample scripts - one that displays a series of messages on factoried instances of a class, another that randomizes a display of images and another that handles book data and outputs the results.

3 comments voice your opinion now!
factory designpattern tutorial introduction


blog comments powered by Disqus

Similar Posts

IBM developerWorks: Use the YouTube API with PHP

Thilanka Kaushalya's Blog: How to use Mysql Transactions with PHP

Zend Developer Zone: Paging Data Sets With PEAR Pager

Matthew Weir O'Phinney's Blog: Cgiapp2 Tutorial 1 - Switch Template Plugins at Will

Adam Pullen's Blog: Execution Filters in Symfony


Community Events





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


symfony series tool voicesoftheelephpant release introduction laravel list version language api community configure unittest composer opinion podcast conference framework interview

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