Re: Clean Object Class Design -- Circle/Ellipse

From: Cagdas Ozgenc <co19_at_cornell.edu>
Date: Mon, 6 Aug 2001 11:39:09 +0300
Message-ID: <9klli4$nbo$1_at_news01.cit.cornell.edu>


> This definition of inheritance is in fact a LSP definition of a
> constrained subtype. If you define subtypes as LSP-subtypes, then yes,
> you can design Ellipse, so that no Circle cannot be made its subtype.
>
> >Hence a Circle derivation is not possible from the above Ellipse class.
>
> LSP-conform derivation.
>
> BTW your perfectly valid Ellipse is by no means perfect. What if
> setAxisA is called with the argument NaN? Will the result be an
> Ellipse? What if the argument is negative?

That's a cheap shot, you are just talking for the sake of talking. Add newA, newB > 0 to the preconditions. Then violating them will simply be a bug in the client side.Moreover if you are not going to conform to LSP, then use containment, not inheritance. Your argument by no means nullify my argument.

> When the postconditions are allowed to be violated for "true
> ellipses", then it should be allowed for a circle as well. Let's
> consider contract violation as a property in LSP sense (:-))

How can you rely on your software if you cannot satisfy the pre/post conditions? Received on Mon Aug 06 2001 - 10:39:09 CEST

Original text of this message