Channels ▼  Christopher Diggins  Dr. Dobb's Bloggers
Composition vs Inheritance  April 23, 2008  In most object-
oriented code inheritance is perhaps the most fundamental
technique of object reuse, but it has several flaws. Object
composition is much more robust, and often more appropriate but
still hasn't become popular. I beleive that this can be
attributed to the fact that object composition is more verbose
than it needs be. I propose the introduction of a new feature to
modern OOPLs to alleviate this: delegation of interface
implementation.  A feature that I haven't really seen in many
languages, and whose ommission has always struck me as odd, is
the ability to delegate an interface implementation. In other
words the ability to declare in a single line of code, the
following pseudo-code:  implement IMyInterface through field
fMyField  This feature would simply be syntactic sugar, but in
many circumstances can save reams of code. It would also make
object composition much more attractive to programmers as