Re: delegation vs. inheritance



On 10 Aug 2006 02:26:27 -0700, Thomas Kowalski wrote:

Hi Dmitry, Steven,

maybe I didn't understood exactly what your discussion is about, but
IMHO the word inheritance is not choosen well. The paradigma
inheritance describes the s/w industrie is simply specialization.

Not necessary. Inheritance is just a way to define a relationship between
two types. Specialization is a specific property of that relationship.
Generalization is another. But the most common case is neither
specialization nor generalization.

Every time we define an objects we are adding constraints. Each
methode, each member constraints this class to an actually usable
"item". Since we say an square is a special rectangle, it would be
perfectly fine too have it "inheriting" is this direction, as you
stated already.

For in-methods, yes. But out- and inout-methods will be broken. Results are
outs.

In fact, you can inherit rectangle from square or square from rectangle,
that changes little.

The Idea of breaking the "contract" with is implied by the constraints
made by a certain class might be a neat feature in some situations, but
is most of the time not neccessary and would just complicate the whole
typesystem.

The problem is that you cannot get a new type without breaking something. A
thing exposing same behavior is just the same thing. It walks like a duck
it quacks like a duck, it is a duck.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: Why is OO Popular?
    ... If square inherits from ... > rectangle can be changed independently, but that's not true for a ... Only the inheritance of mutators breaks LSP. ... In fact, in a large number of cases, descendants might ...
    (comp.object)
  • Re: delegation vs. inheritance
    ... a square all sides are of the same length; and for a rectangle opposing ... Biological inheritance giveth and taketh away. ... The LSP does not hold in biology. ...
    (comp.object)
  • Re: Another Polymorphism question
    ... The object created is of type Square. ... least-derived type in that object's inheritance ... s.Draw() would get the Squares Drawmethod. ... Even the compiler only needs to know the order and nature of inheritance ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Another Polymorphism question
    ... The object created is of type Square. ... Without virtual methods, to get different results from different objects, you have to know the full type of the object and call that specific method using that type. ... But, with virtual methods, that allows code to treat the object using the simplest, least-derived type in that object's inheritance hierarchy that still supports the functionality needed. ... the type itself represents everything the compiler needs to know later when compiling code that uses the type. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: derivable classes [subject change]
    ... > class Square: Rectangle ... > B) A Square is a Rectangle. ... providing a new version of the rectangle with special behavior or added ... which is what inheritance is more about. ...
    (comp.lang.cpp)