On Oct 19, 2007, at 3:52 PM, Mike Schrag wrote:
> This is entirely a personal design preference, because (as you
> mention) this is perfectly legitimate WO code, but you are
> definitely cheating Java's type system. Based on your binding, it
> would appear that your component has an ivar of type Hardware, but
> your component is presuming it to be a Computer.
The HardwareManagement component correctly assumes that "hardware" is
a Hardware type. If I made it a Computer type so that Component
Editor would be happy and assigned a Hardware object to it as would be
correct in HardwareManagement, then the Java compiler wouldn't be
happy or it wouldn't catch incorrect Computer-only messages sent to
the Hardware object. This must be a fairly common situation in O-O
programming, but I may not know the best way to handle it.
> For my money, the most narrow type declaration almost always wins
> out, because there are so many benefits that WOLips/Eclipse can
> provide when done that way.
Hardware is the most narrow type declaration, but that is what is
causing Component Editor to complain. I'd like to do something
reasonable in the Java side to make this work well rather than
flagging wod bindings with "// VALID", but I just don't know what to
do on the Java side other than what I'm doing which is casting
"hardware" to Computer in the ComputerManagement component in which I
know "hardware" will always be a Computer.
Aloha,
Art
This archive was generated by hypermail 2.0.0 : Fri Oct 19 2007 - 22:09:17 EDT