POV-Ray : Newsgroups : povray.off-topic : Messages vs Methods : Re: Messages vs Methods Server Time
6 Sep 2024 03:16:29 EDT (-0400)
  Re: Messages vs Methods  
From: Warp
Date: 27 Feb 2009 18:27:17
Message: <49a876d4@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> http://roots.iai.uni-bonn.de/research/darwin/delegation

  Maybe not completely related, but I find it curious how some
object-oriented concepts talk about inheritance about one class/object
extending another, while others talk about specializing, although they
are technically speaking usually the same thing.

  However, conceptually there's a difference. "Extensions" means,
conceptually, that a class has all the same properties as another class
plus new properties of its own. Thus the inherited class has more features
than the base class, and thus it's an extension of the base class. Some
object-oriented languages even go so far as using the keyword "extends"
to denote inheritance.

  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? Technically
speaking, at the class level, this may be the case, but conceptually it
makes less sense.

  This is where the concept of specialization kicks in. It doesn't make
too much sense to say "Dog extends Animal", but it makes a whole lot more
sense to say "Dog is a special kind of Animal". In other words, Dog
specializes Animal. Animal is a more generic, more abstract concept,
while Dog is a more specific, more concrete concept.

  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.

-- 
                                                          - Warp


Post a reply to this message

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