Abigail said:
(e-mail address removed)-berlin.de (anno4000@radom.zrz.tu-berlin.de) wrote
on MMMMDCCCXXX September MCMXCIII in <URL:"" >
"" > Quoth (e-mail address removed)-berlin.de:
"" > >
"" > > Here lies the objective advantage of inside-out classes: They
"" > > are freely inheritable (can be made base classes, without conflict)
"" > > by any other class, inside-out or not.
"" >
"" > And, almost more importantly, can subclass any other class, inside-out
"" > or not. That is, given a random class Foo whose implementation I am not
"" > privy to, I can create an inside-out subclass Bar that definitely
"" > doesn't tread on Foo's internals. Of course, I can only get at Foo's
"" > attributes through Foo's public methods, but I should be doing that
"" > anyway.
""
"" I believe you mean the technique where one uses the otherwise
"" unused object proper to hold an actual object of the parent
"" class?
""
"" I don't consider that an essential property of inside-out classes
"" but rather a (useful) quirk.
Believe me, the ability of inheriting from any class, regardless of its
implementation was an essential requirement when designing inside-out objects.
"" For one, it renders your class non-inside-out. It touches, err...
"" de-references its body (the parent class' accessors do) and is thus
"" in a state of sin. The result can no longer be used as a base class
"" by anything that isn't compatible with Foo in the usual sense.
Yes, and? Sure, Foo lives in a state of sin from an IOO point of view,
but the assumption is that you don't control Foo. You got Foo from CPAN
or your cow-orker. You control Bar. Now, anyone subclassing Bar (say,
a class Baz) is either an inside-out object, or it isn't. If it is,
it doesn't care how Foo is implemented, so there's no problem. If it
isn't, then Baz itself is living 'in a state of sin'. The restrictions
that are imposed on Baz are done by Foo, not by Bar.
A valid analysis, but I'm thinking not so much in logical but in
psychological or, if you will, marketing terms. Why will IOO
(thanks for the abbreviation) become the standard class implementation
method?
Because the developer of a general purpose class for, say, CPAN (the
market place) wants to avoid everything that might stop a potential
user from using the code. The standard hash implementation allows
other hash-based classes quick-and-dirty inheritance, all others have
to go through contortions to enable full or partial inheritance. Other
implementations tend to be even more restrictive. Only IOO classed are
free of such restrictions, and that makes a *strong* point. Obviously,
I'm only speaking of use by subclassing, other uses of a class are
not impeded by implementation.
On the other hand, a developer who has decided to use IOO is unlikely
to implement the class by subclassing a non-IOO class. That would
spoil the advantage. That's why I consider "upwards inheritablility"
of IOO a more important feature than "downwards inheritablility" for
public classes.
Authors of classes not meant for publication have different criteria,
but they don't decide the race. And even then, I bet most of those
who in fact inherit from a non-IOO class do it "until an IOO-implemen-
tation becomes available".
"" Also, this technique can only be applied once, multiple inheritance
"" from non-inside-out classes requires other means.
As noted in another post, MI is almost impossible in Perl if you don't
control the classes you inherit from. And that has less to do with the
implementation of the classes, but more with the fact that everyone and
his donkey makes the mistake of writing methods that do two unrelated
tasks: constructing an object and initializing an object. Almost all 'new'
methods construct an object, and then stuff the object with attributes.
This is what makes MI almost impossible.
Yes, but that is orthogonal to the type of class. All classes can benefit
from separate creation and initialization (which doesn't mean you can't
have a method that does both).
It is a fundamental fact at least in Perl OO that you need a separate
initializer to do multiple inheritance. You can create an object only
once, but you must initialize it for every class on its @ISA tree.
It is strange that this should have escaped Perl's OO culture for so
long. It must be because inheritance in Perl is (was) cumbersome in
the first place, so it doesn't play the part it could.
Anno