POV-Ray : Newsgroups : povray.off-topic : Messages vs Methods : Re: Messages vs Methods Server Time
9 Oct 2024 08:20:06 EDT (-0400)
  Re: Messages vs Methods  
From: somebody
Date: 27 Feb 2009 19:00:45
Message: <49a87ead$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:49a876d4@news.povray.org...

> In some inheritance hierarchies "extension" is a rational concept. For
>example, if you have a base class named Image, and you inherit from it a
>derived class called PNGImage, which is an Image with PNG reading/writing
>support, you are conceptually extending the base class: It supports
>everything that Image supports, plus more: Reading and writing PNG data.
>
>   However, with other inheritance hierarchies you hit some conceptual
> difficulties. For example, if you have a base class named Animal and
> you inherit a class named Dog from it, can you say that "Dog extends
> Animal"? Is a Dog something which does more than an Animal?

Sure, dog is to animal as PNGImage is to Image. Dog can do things (other)
animals cannot, such as barking. Thus dog extends animal.

PNGImage extending or "descending from" (I seem to like this term better,
more neutral) Image should be as strange (or natural, take your pick) as Dog
descending from Animal. I think the "problem" here is that many people think
of the term "animal" as sum of instances and descendents, rather than the
common denominator. If I tell you that I saw an animal this morning, you
probably come up with mental images of dogs, cats, horses... etc, instead of
mental image of something alive that moves.

>   Personally I think specialization is the better concept in
object-oriented
> inheritance because it can be better applied to almost all (well-designed)
> inheritance situations, while extension can't. For example, you can
> perfectly well say that "PNGImage is a special kind of Image" (ie. one
> which supports PNG reading/writing), in other words, specialization can
> be used at a conceptual level also in this example, while the other way
> around it made less sense.

Yes, it seems to make sense until you get to multiple inheritance and start
thinking about context.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.