Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4 all those years ago...)
Mike Gershman
SCJP 1.4, SCWCD in process
Mike Gershman
SCJP 1.4, SCWCD in process
Mike Gershman
SCJP 1.4, SCWCD in process
Originally posted by David Harkness:
Given all that, one feature I'd love to see is "default implementations" in interfaces: code that would merely be copied (by the compiler) into the implementing class if not overridden by the class itself.
True, this would take some solid analysis and defining, but how many times have you copied the same implementation from class to class?
To make it simpler and easily backwards compatible, Java could define a new type in addition to class and interface (implementor?). You'd write the interface and then a new class type that provides a default implementation for that interface. A class could implement the interface directly, providing its own implementation or "implement" the implementor to get a copy of that implementor's member fields and methods.
[ November 09, 2004: Message edited by: David Harkness ]
Yes, you could do that. The whole point, however, is to avoid copying code again and again. I end up doing this a lot as I tend to build framework code and refactor heavily.Originally posted by Jason Fox:
Couldn't you just write an implementing class, and then point your methods there via a simple object?
Originally, yes, but that would mean changing the definition of an interface, possibly causing backward-compatibility problems. I'd settle for a new type of class/interface.Originally posted by Mike Gershman:
I think David wants the "implementor" methods packaged with the interface so they automatically become members of the implementing class unless they are directly redefined in that class.
Yes, that's certainly the issue. Would it be too naive to have the rule "fields and methods get inherited with precedence ordering based on their ordering in the definition"?Originally posted by Mike Gershman:
If the "implementor" is the only parent, it's just a superclass. If there is another parent, you have diamond inheritance of any methods contained in both parents.
Originally posted by sriram sundararajan:
Thanks for all your answers let me summarize why java doesnot support multiple inheritance in classes. Give me your responses
Since sub class doesnot know which super class to refer as java doesn't support pointer concept. If java is supporting the pointer concept then it will be easy to refer a particular reference from the heap using pointers. Is this answer sounds good? correct me if am wrong.
But here i got one more question why java doesnot support pointer concept?
I want to create a new thread for this topic.
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|