NYCPHP Meetup

[nycphp-talk] OOP noob - general best practices

Michael B Allen ioplex at gmail.com
Wed Jan 20 13:42:27 EST 2010


On Wed, Jan 20, 2010 at 9:39 AM, Yitzchak Schaffer
<yitzchak.schaffer at 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.

A broad description of "OOP principals and best-practices" is far too
involved for anyone to reasonably answer in an email. However I will
contribute one opinion on the topic:

Do not be sucked into OOP hype. I use OOP quite a bit. If you need
polymorphism, it is very powerful. But for some reason many people
seem to think OOP is somehow inherently good and that it should be
used wherever possible. That is a belief I do not support.

Unless you need polymorphic behavior where extending a type so that it
inherits the behavior of another is clearly better, it is very likely
that you can achieve the same objective more efficiently without using
objects at all. This is particularly true in PHP because of the array
type. The array type in PHP is a builtin type and a generic ordered
but hashed container. So if you just need a context to maintain some
state with only one reference - an array is a good option.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/



More information about the talk mailing list