Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

PHPBuilder.com: Using the Factory Pattern in PHP Applications

PHPBuilder.com: Using the Factory Pattern in PHP Applications

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.

Source: http://www.phpdeveloper.org/news/15963

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Posted Luty 26th, 2011 in WEB and PHP Development.

Leave a response: