On Feb 3, 3:50*pm, (E-Mail Removed)-berlin.de (Stefan Ram) wrote:

> tonydee <(E-Mail Removed)> writes:

> >explore what happens when you map that conclusion most simply/naively

> >into an object model: a Circle object as a special case (subclass) of

> >a more general Ellipse. *The answer is that you have Circles that

> >can't do what is reasonable to ask of an Ellipse, namely, alter the

> >ratio of width to height, without ceasing to be Circles. *You hide

>

> * Such an object does not truly model a circle, because a

> * circle cannot be modified.
Indeed

.

> Instead it seem to model a

> * circle storage, which is something different from a circle.

> * The essential property of an ellipse storage is an ellipse

> * /requirement/: It requires a value to be an ellipse (in order

> * to become accepted for storage). Since every circle is an

> * ellipse, every ellipse requirement R also accepts circles. Thus:

>

> x e C *==> *x e E * * *(if x is a circle, then x is an ellipse)

> R a C *<== *R a E * * *(if R accepts ellipses, then R accepts circles)

>

> * The transition from objects to requirements is what actually

> * inverts the direction of the arrow above. It happens to apply

> * to stores, because stores for type T require values to be of type T.
The issue is not with storage: an ellipse can store a circle. But

your statement "if R accepts ellipses, then R accepts circles" is

wrong, given a function R that accepts an ellipse by reference and

attempts to change its height:width ratio. That's the flaw in the

naive OO model... itself an important insight, but again -

understanding this is primarily a basis for discussing how to model

Circles and Ellipses in a more inherently robust fashion....

> >form Mrs Liskov spotlight. *You can try to mitigate the mess by having

> >the Circles throw exceptions, return a success indicator, assert or

>

> * You are calling something a Circle here, what is really a

> * circle storage . This is like calling a numeric variable a

> * number : It is alright as long as you know that it really is

> * storage, not a value.
Wrong. I clearly defined "Circle" and "Ellipse" above in terms of

naive OO modeling, in which Circle is subclassed from Ellipse and

therefore inherits its Ellipse storage.

Regards,

Tony