Re: How much oop is too much oop?




"Nemanja Trifunovic" <ntrifunovic@xxxxxxxxxxx> wrote in message
news:1114473302.444875.73270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

>> Example consider a world with 4 shapes: round, square, triangular
> and irregular with the last being anything other than the first
> three
> a.isRound() a.isSquare() a.isTriangular() may need the
> internal
> representation but a.isIrregular() will just return true if all
> the
> others are false.
>
> Virtual functions were invented exactly to make functions like
> isWhatever() unnecessary.

No. They may make them needed less often, perhaps.

I suspect the trouble may be that the text books tend to give
examples based on a single object hierarchy. When you have dozens
of different objects collaborating in a task, then forbidding one
from asking another about itself and what it can do is extremely
counter-productive.

To continue my trivial example you may have a "plane surface object"
which wants to tile itself with a given shape. It is extremely
convenient if it can ask the shape whether it is one which can be
used for this purpose (like a square or regular hexagon, but not a
regular pentagon). Why hamper things by forbidding the question?

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm


.