Multiple inheritance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple inheritance

Randy Manning
I feel ashamed to ask this question - But I'm just not sure.
Does smalltalk support only single inheritance?

If my understanding is correct, (multiple inheritance) implies that class
"WelderForeman" can be declared as a subclass of both class "Supervisor" and
class "Welder".

(Single inheritance) implies that class "WelderForeman" can only be declared
as a subcalss of either class "Welder" or class "Supervisor" but not of
both.

I thought smalltalk only supported (single inheritance). Am I correct?

Also, if I am correct (smalltalk does only support single inheritance) is
there a simple way to mimic multiple inheritance behaviour within a
smalltalk calss?

~ Puzzled - Randy


Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Ted Bracht-2
Hi Randy,

"Randy Manning" <[hidden email]> wrote in message
news:k%9f8.7858$[hidden email]...
> I feel ashamed to ask this question - But I'm just not sure.
> Does smalltalk support only single inheritance?
>
> If my understanding is correct, (multiple inheritance) implies that class
> "WelderForeman" can be declared as a subclass of both class "Supervisor"
and
> class "Welder".
>
> (Single inheritance) implies that class "WelderForeman" can only be
declared
> as a subcalss of either class "Welder" or class "Supervisor" but not of
> both.
>
> I thought smalltalk only supported (single inheritance). Am I correct?

You are right, Smalltalk only supports single inheritance

>
> Also, if I am correct (smalltalk does only support single inheritance) is
> there a simple way to mimic multiple inheritance behaviour within a
> smalltalk calss?

There is a way (in Dolphin Smalltalk at least), by using protocols. Say in
your example you have a #Welder protocol, and you subclass Supervisor for
your WelderForeman, then you can make the WelderForeman 'obey' the Welder
protocol. This would automatically add the default Welder methods to the
WelderForeman class, which can be specialised of course. It also disallows
you to delete a method that belongs to the Welder protocol.

Hope that helps,

Ted
www.tedbracht.co.uk

>
> ~ Puzzled - Randy
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Clemens Hoffmann
In reply to this post by Randy Manning
"Randy Manning" <[hidden email]> wrote in message news:<k%9f8.7858$[hidden email]>...

> I feel ashamed to ask this question - But I'm just not sure.
> Does smalltalk support only single inheritance?
>
> If my understanding is correct, (multiple inheritance) implies that class
> "WelderForeman" can be declared as a subclass of both class "Supervisor" and
> class "Welder".
>
> (Single inheritance) implies that class "WelderForeman" can only be declared
> as a subcalss of either class "Welder" or class "Supervisor" but not of
> both.
>
> I thought smalltalk only supported (single inheritance). Am I correct?
>
> Also, if I am correct (smalltalk does only support single inheritance) is
> there a simple way to mimic multiple inheritance behaviour within a
> smalltalk calss?
>
> ~ Puzzled - Randy

Smalltalk (at least any commercial Smalltalk) does only support
single inheritence. I don't see this as drawback as it leads to
cleaner design. Mostly multiple inheritence is missused to model
roles. This happens in your example, too

"Welder" is a job description
"Foreman" is a hierarchical position

In my opinion they should not be in one class hierarchy.
The superclass of "Forman" is "Supervisor". this model
the authority hierarchy.

When modelling a employee this employee has a
jobdescription and it is placed into a authority
hierarchy. Therefore the job description and
the position are two different attributes of an
employee. They should not inherrit from each other

Greetings

    Clemens Hoffmann


Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Randy Manning
"Clemens Hoffmann" <[hidden email]> wrote in message
news:[hidden email]...
> "Randy Manning" <[hidden email]> wrote in message
news:<k%9f8.7858$[hidden email]>...
> > I feel ashamed to ask this question - But I'm just not sure.
> > Does smalltalk support only single inheritance?
> >
> > If my understanding is correct, (multiple inheritance) implies that
class
> > "WelderForeman" can be declared as a subclass of both class "Supervisor"
and
> > class "Welder".
> >
> > (Single inheritance) implies that class "WelderForeman" can only be
declared
> > as a subcalss of either class "Welder" or class "Supervisor" but not of
> > both.
> >
> > I thought smalltalk only supported (single inheritance). Am I correct?
> >
> > Also, if I am correct (smalltalk does only support single inheritance)
is

> > there a simple way to mimic multiple inheritance behaviour within a
> > smalltalk calss?
> >
> > ~ Puzzled - Randy
>
> Smalltalk (at least any commercial Smalltalk) does only support
> single inheritence. I don't see this as drawback as it leads to
> cleaner design. Mostly multiple inheritence is missused to model
> roles. This happens in your example, too
>
> "Welder" is a job description
> "Foreman" is a hierarchical position
>
> In my opinion they should not be in one class hierarchy.
> The superclass of "Forman" is "Supervisor". this model
> the authority hierarchy.
>
> When modelling a employee this employee has a
> jobdescription and it is placed into a authority
> hierarchy. Therefore the job description and
> the position are two different attributes of an
> employee. They should not inherrit from each other
>
> Greetings
>
>     Clemens Hoffmann

Clemens,
How organized you are! Must be from all that (single inheritance)
experience.
You are correct. My organizational example (coupled with an ability to use
multiple
inheritance) could lead to an entirly schizoprenic class hierarchy that
would still
function. Who ever thought up "multiple inheritance" after all?

Thank you for you insight.

~ Randy


Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Ian Bartholomew-7
In reply to this post by Randy Manning
Randy,

> Also, if I am correct (smalltalk does only support single inheritance) is
> there a simple way to mimic multiple inheritance behaviour within a
> smalltalk calss?

Just as a historical note - back in the early 90's at least one Smalltalk
implementation included an optional MI addon. From occasional comments in
cls I think the feeling was that it added extra complexity for very little
gain and was dropped in later versions.

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

David Simmons-2
"Ian Bartholomew" <[hidden email]> wrote in message
news:vowf8.2904$OP.56606@stones...
> Randy,
>
> > Also, if I am correct (smalltalk does only support single inheritance)
is
> > there a simple way to mimic multiple inheritance behaviour within a
> > smalltalk calss?
>
> Just as a historical note - back in the early 90's at least one Smalltalk
> implementation included an optional MI addon. From occasional comments in
> cls I think the feeling was that it added extra complexity for very little
> gain and was dropped in later versions.

FYI, while not really appropriate to this newsgroup, it might be of interest
to note that:

SmallScript [AOS and .NET platforms] provides multiple-inheritance of
behavior through mixins. And multiple-inheritance of structure through
interfaces. Where an interface is a subclass of mixin.

Interfaces can be instantiated and can have their own concrete fields.
Interfaces are synonymous with COM interface notions [and support
automatic/transparent exposure as COM objects].

SmallScript is a superset dialect of Smalltalk the language.

-- Dave S. [www.smallscript.org]

>
> Regards
>     Ian
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Dave Harris-3
In reply to this post by Randy Manning
[hidden email] (Randy Manning) wrote (abridged):
> Also, if I am correct (smalltalk does only support single inheritance)
> is there a simple way to mimic multiple inheritance behaviour within a
> smalltalk calss?

There are usually several things going on with inheritance. Reuse of
implementation is one, and it can be simulated using delegation and
call-backs.

Explicit type conformance is another. Smalltalk doesn't need this as it is
dynamically type-checked. For example, your WelderForeman can be used as
either a Welder or a Foreman - it can understand both protocols, both sets
of messages - without needing to inherit from both classes.

  Dave Harris, Nottingham, UK | "Weave a circle round him thrice,
      [hidden email]      |   And close your eyes with holy dread,
                              |  For he on honey dew hath fed
 http://www.bhresearch.co.uk/ |   And drunk the milk of Paradise."


Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

hamburg113
In reply to this post by Randy Manning
Hi,

Thanks very much for this comment. It help me to think about my ideals.

Tks again and pls keep posting.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

hamburg113
If you want to get more materials that related to this topic, you can visit: Structural welder job description

Best regards.