[nycphp-talk] OOP noob - general best practices
Yitzchak Schaffer
yitzchak.schaffer at gmx.com
Wed Jan 20 09:39:38 EST 2010
Hello all,
As I work on refactoring an app I'm working on and getting more of a
feel for OOP, I wonder if folks can recommend any best-practices guides
for general OOP principles. I read most of the Zandstra book, and found
it very helpful for understanding the fundamentals of the OOP approach,
and patterns in particular.
Now I'm looking for something a bit more nuts-and-bolts rigorous; as an
example of couple questions I had recently:
When should one use a factory method
$foo = Foo::factory( $this )
as opposed to using the constructor in the client code
$foo = new Foo( $this )
?
And as corollary, what belongs in a constructor and what doesn't? In
http://www.slideshare.net/sebastian_bergmann/introduction-to-phpunit-best-practices
slides 19-22, Sebastian Bergmann of PHPUnit alludes to this question,
but in that presentation is apparently assuming the audience is familiar
with the answer, and doesn't go into it; his tagline is "don't do work
in the constructor," but rather do something like the following. I
don't know what does and does not constitute "work."
$foo = new Foo( $this );
$foo->build();
Based on Amazon reviews, I just bought a copy of the 1994 ed of
Object-Oriented Software Construction : Bertrand Meyer on Half.com; any
further recommendations?
Thanks,
--
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