[1030] in java-interest
Re: Assertions in Java (& more)
daemon@ATHENA.MIT.EDU (anders@in.otc.com.au)
Thu Aug 17 06:39:11 1995
From: anders@in.otc.com.au
To: johnm@csua.berkeley.edu
Cc: java-interest@java.sun.com
Date: Thu, 17 Aug 95 16:33:13 +1000
Hi John,
You hit on something that I've been trying to get my mind around for a
while now. Why was it necessary to replace mutliple class inheritance
with interfaces?
I haven't had enough OO experience to have run into the problems myself.
But from what I've seen of Eiffel multiple inheritance is extensively
used and to good effect.
I imagine that the problem must be more than just possible name clashing
as the Eiffel rename operator is a simple fix to this.
It seems to me that interfaces may be too restrictive. For a start it
doesn't allow the following
class A {
int method1(); // abstract - no implimentation
method2(); // abstract - no implimentation
method3() { // full implimentation
if (method1())
method2();
}
}
So you can't create methods that build on top of abstract methods.
Or another example
Class B {
int method1(int a, float b, int c); // abstract
int method1(int a, float b) {
method1(a,b,0);
}
int method1(float b) {
method1(0,b);
}
}
which I'm not sure (I must confess) would work in Eiffel
oooo
Also Eiffel lets you defer deciding whether a feature with no arguments
should be a method or an attribute.
i.e
class C {
BOOLEAN feature1; // abstract
}
a class which inherits from C can define feature1 as a method or redefine
it as an attribute.
This allows something like
class foo {
BOOLEAN haveFingers; // abstract
removeFinger; // abstract method
pre condition haveFingers;
}
i.e we can define a precondition based on an abstract feature for another
abstract feature. Whats more since haveFingers has no arguments it may
be implimented as a method or as an attribute (i.e a state variable). (It
could clearly be a state variable that is set by various methods or it
could be a method that performs a count of other state variables.)
So regardless of whether it is a method or a state variable it is an
assertion that is more than a check of "message arguments and their return
values" and still says nothing about implimentation.
Anders Holmgren
Intelligent Networks
TELSTRA
ACSnet: anders@in.otc.com.au
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com