Newsgroups: comp.lang.c++,comp.object,comp.theory,comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!news-peer.gsl.net!news.gsl.net!news.mathworks.com!rill.news.pipex.net!pipex!netcom.net.uk!ix.netcom.com!source
From: source@netcom.com (David Harmon)
Subject: Re: Opinions on Ellipse-Circle dilemma?
Content-Type: text/plain; charset=us-ascii
Message-ID: <332734b9.37761966@10.0.2.1>
Sender: source@netcom23.netcom.com
Content-Transfer-Encoding: 7bit
Organization: Netcom On-Line Services
X-Newsreader: Forte Agent .99g/32.339
References: <5d4fmf$7gk@bagan.srce.hr> <u8rvi86ntcx.fsf@miris10.leeds.ac.uk> <32FA2A1C.6B31@arscorp.com> <5dm3g8$pr6@news2.delphi.com> <32ffa121.20952788@news.igs.net> <3300B1E9.2861@iconcomp.com> <33077e6f.172652070@news.jumppoint.com> <rmartin-2002970736320001@pool10-002.wwa.com> <3312cad5.16666771@10.0.2.1> <rmartin-2102971550340001@pool10-012.wwa.com>
Mime-Version: 1.0
Date: Thu, 6 Mar 1997 07:02:22 GMT
Lines: 29
Xref: glinda.oz.cs.cmu.edu comp.lang.c++:251743 comp.object:61827 comp.theory:18275 comp.lang.smalltalk:52602

On Fri, 21 Feb 1997 15:50:34 -0600, rmartin@oma.com (Robert C. Martin)
wrote:
>For example, I might have the base class Shape, and two derived classes,
>Square and Circle.  I might have a function Shape::Area.  The implementations
>for these functions are radically different for Square and Circle, yet
>they are compatible with the expectations of the users of Shape.

I read that.  I read the Liskov Substitution Principle which you
quoted elsewhere.  And, I come down to two possibilities:

   Shape is an abstract class.   Not very far from my question about
inheriting from interfaces only.  LSP does not apply, since it is
defined in terms of classes that can be instantiated only.
-or-
   Shape is a concrete class.  A program that expects Shape::Area() to
return a particular value (after setting Shape::Size(x) say) will fail
when presented with at least one of either Square or Circle.
Therefore these classes cannot satisfy LSP.

>The new behavior of the derived class can be *different*, and yet 
>*compatible* with the expectations of the users of the base class.

Yet any difference at all would cause some program P to change it's
behavior when an instance of the derived class is substituted for the
base class.  Indeed, merely a different value returned from
Shape::Area and printed would constitute a change in behavior.

Am I missing something?  Unfortunately, I have not read Liskov's
paper, which would undoubtedly explain much.
