On Wed, Jan 20, 2010 at 9:39 AM, Yitzchak Schaffer <yitzchak.schaf...@gmx.com> wrote: > 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.schaf...@tourolib.org > > Access Problems? Contact systems.libr...@touro.edu > _______________________________________________ > New York PHP Users Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/Show-Participation >
I suppose this might be a little taboo on a PHP list, but Thinking In Java is hands down the best OOP guide I've ever seen, let alone read. As a positive side-effect, you get to learn Java, but there's no better place IMHO to learn object orientation. And it's free[1]! [1]: http://www.mindview.net/Books/TIJ/ _______________________________________________ New York PHP Users Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/Show-Participation