[1947] in java-interest

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

Re: interfaces?

daemon@ATHENA.MIT.EDU (andrew (a.) francis)
Wed Sep 20 14:25:43 1995

Date:  Wed, 20 Sep 1995 10:33:00 -0400 
From: "andrew (a.) francis" <andrewfr@bnr.ca>
To: java-interest@java.sun.com

In message "interfaces?", you write:

[example deleted]

> Forget about multiple inheritance. The real beauty of this, is that
> unlike C++, you no longer have to distribute a .h file, that contains
> more information about the class than you would like to share.
> Plus, you can interface to potentially ANY object, not just an object which
> happens to be a subclass of "X".

I have been wondering why interfaces are more desirable than MI and
I have come to the conclusion that MI is still more powerful mechanism
but interfaces with a change in programming strategy are an adequete
substitute (I am still getting use to Java). But by stating that the real
beauty is the lack of a .h file, I feel does not touch on the issues.
Unfortunately, I am not an expert on the more theoretical issues concerning 
OO but I think a good way of looking at the issue is viewing objects as 
having a type and a behavior. In turn, the interface is the type, and the class is the behavior.
That said, interfaces allow objects to more conveniently incorporate types
while multiple inheritances allows for more convenient incorporation of
both type and behavior.  I can see interfaces being very useful in cases 
involving sub-type polymorphism and control abstraction (i.e sending an open
message to list of windows, each window behaving differently to the open message) as opposed
to reuse I believe if this wasn't the case, then abstract classes alone would
do in Java.

By the way, there is a nice discussion entitled "Class versus Interface
Inheritance" in the excellent book "Design Patterns." I believe Coplien
in "Advanced C++ with Idioms" also discusses this issue.

Still, I wouldn't mind knowing exactly what interfaces do at run-time
(i.e one of the Sun developers mentioned that casting to an interface
was lighter weight than casting to class, why?)

Cheers,
Andrew
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

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