News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
PHPImpact Blog:
Static Factories vs Public Constructors
July 18, 2008 @ 12:58:31

On the PHP::Impact blog Federico Cargnelutti has posted a comparison of using static factory methods to create an instance of a class versus making an object, calling the constructor.

Normally, creating an instance of a class is done by calling new, which calls the constructor. Static factory provides a static method that returns an instance of the class. So, you are using static factory instead of the constructor. Providing a static factory method instead of a public constructor has both advantages and disadvantages.

He includes some of the advantages of the factory method and others for the normal call to create an object. He also mentions some comments made by Dagfinn Reiersol in a blog post about public constructors.

0 comments voice your opinion now!
static factory designpattern constructor object instance



Similar Posts

DevShed: Processing File Data with Template Classes in PHP 5

Cocoliso's Blog: Adding A Syntax Highlighter To Your Site: The Power Of Geshi

DevShed: Processing File Data with Template Classes in PHP 5

Andy Frey's Blog: JavaScript PHP Remoting Demonstration

Pavel Shevaev's Blog: A reliable way to serialize/unserialize objects in PHP


Community Events











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


ajax mysql database framework package code example job zendframework releases release book conference application developer zend PEAR PHP5 cakephp security

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