PHP Classes, Avoiding Extends

This article is a followup to [PHP Constructors, Cascading Them].

The prior version of this document described a way to extend in a non-intuitive way. It seemed clever at the time, but, after some more drinking of the Design Patterns kool-ade, I'm fully recanting my prior position. "extend", which I was already wary of, is no longer my friend. Loose couplling is the way to go.

"Extends" should be reserved for classes that actually extend each other, and really benefit from tight coupling between classes. In all other situations, use loose coupling. If you need the functionality of an object, instnatiate it and send a message. this is like a throwback to library-style programming.

One exception is when you create abstract classes in PHP. Then, you must use "extends" because the abstract class cannot be instantiated.