[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OO should break when broken(was re: the benefits of immutability)

> On Monday, September 1, 2003, at 06:14 AM, Colin Putney wrote:
> > An ellipse is a circle with additional capabilities - it can have
> > different radii along each of its dimensions.
> This reminds me of something that bothers me about OO:  the
> accumulation of unused stuff.  When I extend Circle to make Ellipse, I
> add x-radius and y-radius, but the original radius instance variable is
> still there.  Since I'm not going to use Circle's radius any more, I
> wish I could just ask it to go away, if the compiler or runtime could
> verify it isn't needed by methods I decide not to override.

When you want things in the superclass to "go away", it points to bad
design. It can be very confusing when you come across a system that where
subclasses are designed to ignore various things they inherit.

I don't think an ellipse is a kind of circle. It would make more sense for a
circle to be a kind of ellipse. The problem seems to be that the "extends"
relationship doesn't mean the same thing as "is-a", "a-kind-of" or