[5866] in java-interest

home help back first fref pref prev next nref lref last post

Re: keyword to introduce a method?

daemon@ATHENA.MIT.EDU (garya@ics.com)
Fri Mar 1 05:42:50 1996

From: garya@ics.com
Date: Fri, 1 Mar 1996 02:39:37 -0700 (MST)
To: Mike Afergan <mikea@ai.mit.edu>, garya@dreamchaser.org,
        strong-java@entmp.org
Cc: java-interest@java.sun.com


>>When writing a class, one could then use:
>>
>>public class Derived extends Base {
>>	intro public int foo() {...}
>>}
>>
>>to indicate that the function is being introduced (i.e. is rooted at this
>>node in the class hierarchy).

>        Admittedly your idea has some merit, but some flaws as well.  First
>of all, if the authors of Derived and Base are so distant as to not know of
>eachother's work

The author of Derived obviously knows of the author of Base's work.
However, the author of Base is expected to know nothing about any additional 
functionality added in classes derived from Base.  It's one of the basic
precepts of subclassing.

>        Furthermore, I couldn't help but notice that your "intro" modifier
>concept would require that every method (I'm assuming you could apply it to
>fields as well.) added to a class that has been available to other
>programmers would require an "intro" modifier.  

Good practice would mean the intro modifier would be added whenever
you introduce a new method in a class; but not when overriding a method
from a base class.  It need not be required.

>Thus, after a few revisions,
>virtually all methods would have an "intro" modifier,

No; only methods which are new to the class derivation.
Overridden methods are not newly introduced.

> thus producing warning
>messages all over the place - even if a programmer knew EXACTLY what he was
>doing.

No.  There would be zero warnings in a program which worked correctly.
There would only be warnings in a program which potentially misbehaves;
currently there are no warnings, you just get buggy behavior.

>        Without doubt, this is a sticky problem with no perfect solution -
>except good code management and planning.

I disagree; the proposed modification produces warnings *only* when the code
can misbehave.

Gary Aitken		garya@ics.com         (business)
			garya@dreamchaser.org (personal)
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post