Re: to subclass or separate

From: Bjorn Abelli (bjorn_abelli_at_DoNotSpam.hotmail.com)
Date: 03/17/05


Date: Thu, 17 Mar 2005 18:35:57 +0100


"Matt Humphrey" wrote...
>
> "Bjorn Abelli" wrote

>> ...or something in between, i.e. that you maybe should construct another
>> superclass (abstract) with the parts that are the same in both Message
>> and
>> Reply, and let them both be subclasses from a common superclass.
>
> That certainly is another way to setup inheritance. I would still make
> the
> decision to use inheritance or not based on whether the objects were
> variations of some kind or whether their similarities were superficial. I
> would try to avoid using inheritance to share implementation details of
> objects that are not strongly related.

Exactly, it all boils down to in what way the concepts are related, which
really only the OP can figure out.

It did sound to me as both "Message" and "Reply" are two different types of
a common concept, actually of some "MessageType", but still differ in
significant implementation details, so one not can say that a "Reply" is-a
"Message" or vice versa, but they can both be said to be of some
messagetype, just like cats and dogs both are mammals, and thus share some
traits...

// Bjorn A



Relevant Pages

  • Re: delegation vs. inheritance
    ... I intended not to describe implementation inheritance but specification ... interactions involving superclass instances were modeled. ... responsibility is defined in one and only one place: ... the superclass responsibility correctly for the client context. ...
    (comp.object)
  • Re: Reference overloading helps inheritance
    ... > AS> Inheritance in Perl OO has its difficulties when it comes to data ... > AS> implementation of the superclass. ... Perl should know about. ... establishing the HAS-A relation in the first place), ...
    (comp.lang.perl.misc)
  • Re: Reference overloading helps inheritance
    ... AS> Inheritance in Perl OO has its difficulties when it comes to data ... AS> implementation of the superclass. ... AS> Time::Piece does, this means I can compare tapes with each other, or ... Search or Offer Perl Jobs ...
    (comp.lang.perl.misc)
  • Some questions about inheritance
    ... I have some questions about inheritance that I want to have an answer to. ... It says "Abstract superclasses define a behavioral pattern without ... What does it actually mean with saying that an Abstract superclasses define ... subclass "is not a" superclass, ...
    (comp.object)