On 1/20/2010 11:34, Paul A Houle wrote:
Another one is that Foo::create() can return false or null rather than
throwing an Exception; that said, much of the time throwing an Exception
is a better error handling mechanism than returning "nothing".
That's actually one way I've used the static factory - to handle a
situation where there is no Bar that can be created from Foo, but this
is expected:
$foo = new Foo();
$bar = Bar::factory( $foo ); // false
if ($bar) {
// do stuff with $bar
}
Is this good practice? I think my question of client-calls-constructor
vs. factory came out of the fact that so many of my classes fall into
this category.
--
Yitzchak Schaffer
Systems Manager
Touro College Libraries
33 West 23rd Street
New York, NY 10010
Tel (212) 463-0400 x5230
Fax (212) 627-3197
Email [email protected]
Access Problems? Contact [email protected]
_______________________________________________
New York PHP Users Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org/Show-Participation