(e-mail address removed) wrote: ....
Delegation is not an alternative to OOP. It works fine with OOP.
No. And Java does not support multiple inheritance.
Java supports multiple interface inheritance. Some OO languages
have no concept of implementation inheritance and support
multiple inheritance, so I think your statement needs
clarification.
"Java supports multiple interface inheritance, but does
not support multiple implementation-inheritance... And
implementation-inheritance has nothing to do with OO".
I *think* what the OP refers too is that the most
common (broken) complain about Java regarding inheritance
is that people cannot "reuse code" [sic] from several classes.
What these people want to do can easily be achieved by
using multiple interface inheritance and delegating the
calls to wrapped objects.
So delegation is not an alternative to OOP, but it can
be used to easily circumvent the "problems" of not having
multiple implementation-inheritance.
I *think* this is what the OP's question is about.
300K LOC project here with zero instance of the keywords
"abstract" and "protected" and where every single class
is final. It can be done, and it's actually done (and
sometimes enforced by guidelines and build scripts) in
several projects.
Once again it should be noted that James Gosling himself
expressed regret not having gone "pure interface", leaving
that ugly implementation-inheritance wart on the side
(that is an opinion of course, which just happens to match
the opinion of Java's creator
Direct link to the paragraph where James Gosling explains
how delegation can be used to fix implementation-inheritance
problems [sic]:
http://www.artima.com/intv/gosling34.html
B.V.:: Bill Venners: But by delegation, you do mean this
B.V.:: object delegating to that object without it being a subclass?
J.G.: James Gosling: Yes -- without an (concrete) inheritance
J.G.: hierarchy. Rather than subclassing, just use pure interfaces.
J.G.: It's not so much that class inheritance is particularly bad.
J.G.: It just has problems.
Java would actually have been more elegant without implementation
inheritance: no more "abstract" keywords, no more final/non-final
class distinction (they would all have been final).
Once again it's just an opinion.
But Java does support multiple inheritance and OO analysis/design
requiring multiple inheritance can be programmed in Java in a
very simple (and in my opinion very clean) way,
Driss