Xref: utzoo comp.lang.c++:3320 comp.lang.eiffel:187 comp.lang.smalltalk:1072 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!pt.cs.cmu.edu!pt!dld From: dld@F.GP.CS.CMU.EDU (David Detlefs) Newsgroups: comp.lang.c++,comp.lang.eiffel,comp.lang.smalltalk Subject: Re: Use of inheritance for classification? Message-ID: Date: 15 May 89 20:43:46 GMT References: <30582@apple.Apple.COM> <6365@brunix.UUCP> Organization: CMU CS Department Lines: 41 In-reply-to: bpe@brunix's message of 14 May 89 01:04:07 GMT Page Elmore writes -- >I do not think that inheritence is ever classification: it is specialization. >This misconception will cause you lots of trouble when you attempt to define >a class hierarchy. Classification implies something like: > > Type Car > color:Red, Blue, Grey, Black, White, etc. > | > | > | > Type Honda CRX (inherits from Car) > color: Red, Black >Thus you attempt to constrain the value class of the color attribute, causing >no end of trouble code which attempts to use a Honda CRX in place of a Car. If this is classification, what is it that you think of as specialization? Whatever you call it, I think this is exactly the kind of use of inheritance that Meyer and Liskov, among others recommend. I don't see where the fact that the set of colors that a Car may be is larger than the set of colors supported by HondaCRX. To make this work properly, you would only be allowed to specify the color of a Car at the time of creation. If you created a more specialized (or "classified" -- I really don't understand your terms) Car like a HondaCRX, it's creation function would constrain the set of acceptable colors. After creation, HondaCRX should fulfil Car's specifications of each of it's operations. I really think this works out fine, and is the right way to use inheritance. Meyer's book and Liskov's article in OOPSLA (87? 88?) make this point persuasively. -- Dave Detlefs Any correlation between my employer's opinion Carnegie-Mellon CS and my own is statistical rather than causal, dld@cs.cmu.edu except in those cases where I have helped to form my employer's opinion. (Null disclaimer.) --