Re: How much oop is too much oop?
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 26 Apr 2005 08:31:41 +0100
"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
.
- Follow-Ups:
- Re: How much oop is too much oop?
- From: Jerry Coffin
- Re: How much oop is too much oop?
- From: Torsten Mueller
- Re: How much oop is too much oop?
- References:
- How much oop is too much oop?
- From: ben
- Re: How much oop is too much oop?
- From: Gene Bushuyev
- Re: How much oop is too much oop?
- From: David Webber
- Re: How much oop is too much oop?
- From: Nemanja Trifunovic
- How much oop is too much oop?
- Prev by Date: Re: How much oop is too much oop?
- Next by Date: Re: How much oop is too much oop?
- Previous by thread: Re: How much oop is too much oop?
- Next by thread: Re: How much oop is too much oop?
- Index(es):