[Prev][Next][Index][Thread]

Re: MI: why?



For one thing, it allows what is called in some contexts "mixins", which
means if you need some features you inherit from a class which offers
them.  Say for example you have a class called "Persistent" which
allows an object to be streamed to a database and restored.  Then
regardless of whatever other type this class derives from, you can add
"Persistent" to its base class list and then save and restore it
directly.

You might have:

class Panda isa Persistent, Bear;

p = new Panda;

p->save;
p->restore;

(This is not Dylan syntax of course, but it illustrates one small
advantage to MI.)

> > > As for Smalltalk, single inheritance is just flat out a mistake in
> > > language design. (If you disagree, don't bother trying to convince me,
> > > because you won't create even the tiniest bit of doubt in my mind.) I
> > > cannot stand the thought of learning another of those SI class libraries
> > > with an outrageously deep hierarchy with functionality pushed up into
> > > totally counterintuitive classes in order to get it where it can be
> > > shared. A well-designed MI-based framework/library is so much easier to
> > > understand and extend than an SI one.
> >
> > I agree 100%.
> 
> Now this is interesting. I try to learn by other's mistakes and from other's
> advice, and I have heard a lot of condemnation of multiple inheritance.
> Consequently I have carefully avoided it when it is present (C++ - may it rot) and
> not missed it when it isn't there (delphi - but then delphi is primarily used by me
> as a database front end, so it's a bit irrelevant). I don't condemn MI and I would
> rather a language provided it, so I could ignore it, rather than be denied it by
> someone else's choice.
> 
> I can imagine rare cases where it might be valuable but I haven't personally come
> across them yet. I am wondering if MI from purely abstract base classes is at all
> bad. I don't like the feel of MI from non-abstract base classes - it doesn't feel
> right.
> 
> Please tell me more about why MI is good/bad/misused/whatever. I feel that I may be
> missing out on a valuable facility.
> 
> thanks
> 
> jt
> 
> 
> 
> 


References: