|
|
|
|
|
by AndrewO
5697 days ago
|
|
In addition to what the others said, these two pages make the arguments that convinced me: http://blogs.msdn.com/b/scottdensmore/archive/2004/05/25/140... http://www.c2.com/cgi/wiki?SingletonsAreEvil I don't know the particulars of how PHP's ArrayObject works, but take Ruby for example: instead of inheriting from Array, to make a class that operates like an array, one mixes in the Enumerable module (similar to a trait) and implements an "each" method to handle the low level access. All of the other methods come along with the module. In this way, the lineage of a class isn't important; rather, it's what it actually does that matters. (How meritocratic! :-) But particulars of any language aside, I think this is an important step for PHP. Once a language gives the ability to compose the behavior of a class through traits, modules, mixins, etc rather than standard inheritance, it becomes easier to separate the data that a class encapsulates from the behaviors that it provides—and that, I believe, leads to more modular code. |
|