On 5/27/10 12:10 PM, Adam Richardson wrote:
I've thought about this very issue before (java developers sometimes lament
this issue, too), and I error on the side of duplication if I'm using
However, I'd say I rarely use inheritance for anything in my development,
and I'm much more likely to use composition.
When a project evolves that's built almost entirely using design patterns
focused on composition, I find that I very rarely have to duplicate any
documentation, or rework documentation later on because a completely new
component is being used.
Outside of PHP (Scala, Objective C, F#, etc.), it seems like inheritance is
advocated much less frequently, due to the power and simplicity of
composition (e.g., change behavior at runtime, requires less knowledge of
the parent classes.)
Quoting the Head First book on design patterns:
"Favor composition over inheritance"
I agree entirely there. :-) However, the same question applies when
using interfaces (which are common if you're doing composition). See
the language example I had earlier. Where should the documentation of
the hello() method go? the Talk interface, the TalkInKlingon class, the
TalkInSpanish class, all three...?
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php