Re: Ridiculous question ?
Daniel Moyne wrote:
The need for this may appear in the following case and I think this is quite typical :
It is not typical.
- you have a parent instance with its own methods ; everything works fine
but you think that part of the code can be profitably used by others objects ;
then you decide to create Some_Class to handle this.
The word "parent" is misused here. A "parent" typically means the
supertype of the invoked class.
Assuming you actually mean "invoking instance" rather than "parent
instance", what you want to do is bad design. Invoked objects almost
never should call methods of the invoking instance. To do so limits
the invoked instance to use only with the invoking class. If that's
what you need, then the invoked class should be an inner class of the
invoking class. Then you have the access you want.
If the invoked class is not an inner class of the invoker, you almost
never should couple it to the invoking type that way.
- unfortunately by doing so you loose [sic] the direct connection with the methods of
That's not unfortunate at all.
the parent instance which in my case are (for some of them) still needed -
Then your design is wrong. Think again.
this especially may appear in handling events that will then be transferred
to the child instance where the process may still need to call some methods
of the parent.
If you really need this, make the invoked type package-private or an
inner class of the invoker.
--
Lew