View Single Post

  #7 (permalink)  
Old 08-13-2003, 01:18 AM
Anthony Lander
Guest
 
Posts: n/a
Re: Extends is evil?

panu wrote:

>> The correct relationship is part-of. People are part-of a ChessClub in
>> the same way that an engine is part-of a car.

>
> Almost, in my opinion. Consider that 'people' is a set/plural
> but 'engine' is a singular element. Therefore I think we should
> say: "A set of people can be a *subset* of a ChessClub".


Actually, a chess club has a collection of people; The collection of people
is a part of the chess club. No different than an engine is part of a car.

> I gather what you're saying is that if there is a proper
> type-of relationship between two classes, /then/ it is ok
> (= safe) for the subtype to inherit implementation from
> its supertype. Right?


Code sharing and subtyping are orthogonal. You can have code sharing
relationships with no subtyping, and you can have subtyping relationships
with no code sharing.

In Smalltalk, it so happens that there is only one hierarchy, namely the
code sharing hierarchy, which forces us to conflate code sharing and
subtyping. On the surface this looks like a compromise, but in reality it
is quite elegant: Code sharing (good for the implementor) and
substitutability (good for the user) are expressed in exactly the same data
structure!

-anthony (a Wilfian dogmatist if ever there was one)
Reply With Quote