Re: Polymorphism sucks [Was: Paradigms which way to go?]



CTips <ctips@xxxxxxxxxxx> writes:

> topmind wrote:
> <snip>
> > OO is good for .... shapes.
> >
>
> Not really. Anytime someone comes up with the shapes example, ask them
> how they would add the method:
>
> class shape {
> // true if object has any points in common with <B>
> boolean intersects(shape B);
> }
>
> See how quickly mind-lock sets in....

I believe this criticism is not a fair comment.

The reason that this problem is difficult is that intersection on
general shapes -- with no restrictions on what kinds of shapes might
be intersected -- is non-obvious whether objects are used or not.
Using OO techniques doesn't automatically confer a deep understanding
of the problem domain.

A better test would be to take someone who understands the problem of
shape intersection (and is agnostic about objects) write code to
perform shape intersection using both an OO approach and a non-OO
approach, and compare the results.
.