[nycphp-talk] OOP noob - general best practices
Yitzchak Schaffer
yitzchak.schaffer at gmx.com
Wed Jan 20 11:45:39 EST 2010
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 yitzchak.schaffer at tourolib.org
Access Problems? Contact systems.library at touro.edu
More information about the talk
mailing list