That is far from an uncommon idea. The phrase to search for to learn more about this is "Composition over Inheritance". That leads you to e.g. http://en.wikipedia.org/wiki/Composition_over_inheritance or, combined with "site: c2.com" to http://c2.com/cgi/wiki?CompositionInsteadOfInheritance or http://c2.com/cgi/wiki?UseCompositionAndInterfacesWithoutCla....
In some sense, deep inheritance hierarchies were a thing of the 80's, when inheritance was new (at least, in the mainstream), just like the <blink> tag was a thing of the '90s (or was that the 00's?). Now, deep hierarchies are a code smell.
80's!?!
OO only started to get into the enterprise in the 90's.
That is funny because my limited experience with Python, on-off over the years, it was impressed upon me many, many times composition is superior to inheritance, and the language even has both built-in.
And yes, for all the pointy-hairs around, I know there are exceptions to the rule. I am speaking generally.
Javascript supports prototypal inheritance natively and it works well. The problem is people trying to fit every java oo concept in js, ending up writing unreadable mess.
Re:Instance Model Programming in C
by discreteevent on Monday November 25, 2013 @06:57PM
(#6798031)
I agree and I think that this is what Go gets right. The thing that's valuable about objects are the interfaces (Alan Kay said it was the messages). Microsoft's COM is similar in this regard.
I really like OO programming (i.e. I'm particularly not one of the functional-fundamentalist OO-haters here on HN), but as I've grown more experienced, I've started to use inheritance less and less, and composition more and more. This is trivially supported in C structs, and you don't need any fancy approach for it, plus you can do with way less void pointer casting, which means less runtime errors.
Inheritance is very useful for a small set of relatively complex problems, such as language parsing or UI frameworks or particle simulations. For many other problems, including most applications (as opposed to libraries), however, my experience is that you can do fine without. This holds especially these days, when many of said complex problems are solved in excellent freely available open source projects, in nearly any language.