View Single Post

  #6 (permalink)  
Old 08-12-2003, 10:13 PM
Carl E Gundel
Guest
 
Posts: n/a
Re: Extends is evil?

Guillermo Schwarz <guillermo_schwarz@hotmail.com> wrote:

: "Peter van Rooijen" <peter@vanrooijen.com> escribi en el mensaje
:>
:> It seems that there is some confusion over what the term "implementation
:> inheritance" actually means.
:>
:> Implementation inheritance refers to the situation where one class
: inherits
:> another, without a resonable subtyping relationship between the two.
:>
:> An example would be to think that a chess club is a set of people, and
:> translating that into defining a class ChessClub that inherits Set.

: Why? It has a set of people, why would that be a problem?

The ChessClub should have an instance variable to hold the collection.
The Set (or whatever kind of collection you wish to use) of people is just
one attribute of ChessClub.

What if I have a subclass of ChessClub and I want to use some other kind
of collection other than Set (a Dictionary maybe, or some sort of
persistence managed store for example)? Do I add an instance variable to
my subclass of Set to hold this special kind of collection? Get's ugly.
If the instance of set is in an ivar, I can change it to whatever I like.
Also, maybe my ChessClub has no need for all the semantic baggage of Set
(more than 60 methods in the flavor of Smalltalk I use).

-Carl
------------------------------------------------------------------
Carl Gundel carlg@libertybasic.com Shoptalk Systems
author of Liberty BASIC, twice a PC Magazine Awards Finalist!
http://www.libertybasic.com
------------------------------------------------------------------
Reply With Quote