Re: Inheritance and Polymorhpism (getting back to the point)
From: Graham Perkins (grahamPerk_at_hotmail.com)
Date: 11/26/03
- Next message: Graham Perkins: "Re: Refactoring a Swing GUI"
- Previous message: Daniel Parker: "Re: Refactoring a Swing GUI"
- In reply to: Isaac Gouy: "Re: Inheritance and Polymorhpism (getting back to the point)"
- Next in thread: Isaac Gouy: "Re: Inheritance and Polymorhpism (getting back to the point)"
- Reply: Isaac Gouy: "Re: Inheritance and Polymorhpism (getting back to the point)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Nov 2003 06:00:32 -0800
igouy@yahoo.com (Isaac Gouy) wrote in message news:<ce7ef1c8.0311241439.488a5749@posting.google.com>...
> grahamPerk@hotmail.com (Graham Perkins) wrote in message news:<9b3b5be3.0311240157.597a2b14@posting.google.com>...
> It seems that your meaning of inheritance does not distinguish between
> sharing an implementation and sharing an interface - it includes both
> meanings.
I cannot help the way "inheritance" has become widely accepted
and implemented. Just looking at a few, (eg Eiffel, C++, Smalltalk,
Java, Borland Pascal, C#) we can see several flavours of inheriting
both implementation and interface, separately or together.
> (It seems that if the interface is behaving exactly like a pure
> abstract class then you regard it as the same as a class
If you want to say that the Java class hierarchy defining type
conformance and allowing polymorphism is "inheritance" and the
interface hierarchy defining type conformance and allowing
polymorphism is something else, then go right ahead! Then we
will have nothing to disagree about.
> Does Java reflection meet your requirements?
It could do. Here's an example from my MVC framework:
-- assume Product has setQty and getQty methods
Product p = ...
IntAdaptor qtyEdit = new IntAdaptor( "getQty", "setQty", p );
Now inside the guts of IntMapper, reflection is used to
call those named methods in p whenever the adaptor's set
and get methods are called:
qtyEdit.setValue( 5 ); -- calls p.setQty(5)
n = qtyEdit.getValue(); -- calls p.getQty()
The polymorphism comes in because I allow the target of the
adaptor to be switched:
qtyEdit.setTarget( anotherProductInstance );
Now the adaptor's set/get calls will bind to the "getQty"
and "setQty" methods in the new target, which may be different
actual methods. The new target doesn't have to be a Product
or Product subclass, so long as it implements getQty and setQty.
However, I'm effectively coding up my own binding mechanism
using reflection (which is exactly what Smalltalk does). I
suspect that this is a rather uncommon way of using reflection,
and generally its use in Java is orthogonal to polymorphism.
- Next message: Graham Perkins: "Re: Refactoring a Swing GUI"
- Previous message: Daniel Parker: "Re: Refactoring a Swing GUI"
- In reply to: Isaac Gouy: "Re: Inheritance and Polymorhpism (getting back to the point)"
- Next in thread: Isaac Gouy: "Re: Inheritance and Polymorhpism (getting back to the point)"
- Reply: Isaac Gouy: "Re: Inheritance and Polymorhpism (getting back to the point)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|