fabrulous@yahoo.fr
6/7/2006 11:15:00 PM
Hi all Rubyers,
I'm considering trying out Ruby. I've got a very specific question: is
it possible to define an abstract data type without tying it to any
implementation?
Note that I'm not debating on the merits of doing that, I'm simply
asking if it's possible in Ruby.
This is doable in Objective-C, in C++, in Java and in C#, for example
(this is definitely *not* the way 99% of Java/C++/C# programmers code
though).
Many programmers consider that OO implies concrete/implementation
inheritance, others (a minority) don't. Once again I'm not debating
the merits of doing that, I just want to know what are the options to
model OO hierarchies in Ruby and if it's possible to model entire OO
hierarchies without being tied to any implementation.
In Java this is possible by only defining ADTs using interface and
"interface inheritance" to model OO hierarchies, in C++ this is
possible by only defining ADTs using "pure abstract classes" (something
Stroustrup has been advocating since 1987 or so, see my .sig), etc.
If it's possible to model an abstract data type in Ruby without being
tied to any implementation detail, how is "code re-use"/"behavior
inheritance" (though I don't like that term very much) done? (in Java
it can be done using delegation, in Objective-C using class cluster,
etc.)
What about multiple inheritance ? (For example in Java it's possible
to define an OO hierarchy in a purely abstract way by two different
methods: using only interface and interface inheritance or using only
pure abstract class [ie abstract class not carrying any method nor any
state]... But in that later case you can say goodbye to multiple
inheritance).
Once again, I'm not asking for something very common nor very
entrenched in people's mentalities, but I just want to know if it's
doable.
Thanks in advance for any infos on this,
fab
--
"Since then (1987) I have consistently pointed out that one of the
major ways of writing classes in C++ is without any state, that is,
just an interface."
Bjarne Stroustrup (on "Modern C++ Style")