Re: How much oop is too much oop?
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Apr 2005 09:25:26 +0100
"Jerry Coffin" <jcoffin@xxxxxxxxx> wrote in message
news:MPG.1cd8c825742a9999896b0@xxxxxxxxxxxxxxxxxxxxx
>> 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.
>
> Rather the contrary -- it's often a good thing to do. Allowing
> such
> questions to be asked almost always leads directly to _requiring_
> that they be asked to use them correctly.
I am afraid I don't accept that at all: all operations should of
course be perfectly fail safe. Just because you permit quick tests
on whether they'll work, in no way implies that you must rely on
those tests being made first.
> This means two things
And so the rest is a complete non-sequitur. Just because something
*can* be done in no way implies it *has* to be done. The principle
of making operations failsafe, is in no way violated by simply
providing quick tests to see if you know they're going to fail in
advance.
> If tiling is important in your application, you can make that
> explicit:
>
> class shape {};
>
> class tileable_shape : public shape {};
Of course you can. For an object with N boolean attributes which
are important to you, you can create 2^N derived classes so that you
have one with every possible combintion of attributes. I don't envy
you writing a program that way though.
> Of course, it's also possible to go overboard with this --
> attempting
> to encode _lots_ of characteristics into the types can lead to
> deep,
> brittle hierarchies.
Or very broad ones.
Consider this: the strength of object orientation comes from the
fact that it models the objects and procedures of real life. In
real life you know that if you have a stack of regular pentagons,
then you can't tile the plane with them. You don't start trying.
In real life you *can* look in the varnish pot to see if it is empty
and you don't (at least I don't) start doing a long operation which
a few hours later will require it to be full.
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?
- 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
- Re: How much oop is too much oop?
- From: David Webber
- Re: How much oop is too much oop?
- From: Jerry Coffin
- 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):
Loading