Prev: Call for Papers Reminder (extended): World Congress on Engineering and Computer Science WCECS 2010
Next: connection pool
From: Screamin Lord Byron on 26 Jun 2010 09:32 On 06/26/2010 03:15 AM, Eric Sosman wrote: > That way lies madness. There are no Parrot instances in > the real world, True. > Since the human mind is too small to > encompass all individual things in Nature or in imagination, it > is eventually necessary to generalize, True again, but it has nothing to do with the size of the human mind. Even if the human mind was infinite, you still wouldn't have actual animals and birds and parrots and Pollys in it, only their abstract representations. > to lump a whole aviary > of Pollys and Snoofleses and FeatheredBastards and so on into > Parrot. Or, let it be said, into Bird. You will lump it according to your lowest needed level of abstraction. If your lowest level of abstraction is bird, then you'll only have instances of the Bird class, but not instances of the Animal class. If your generalization needs to be more specific, then you'd have instances of the Parrot class, but not of the Bird and the Animal classes.
From: Patricia Shanahan on 26 Jun 2010 09:40 Screamin Lord Byron wrote: > On 06/26/2010 03:15 AM, Eric Sosman wrote: .... >> to lump a whole aviary >> of Pollys and Snoofleses and FeatheredBastards and so on into >> Parrot. Or, let it be said, into Bird. > > You will lump it according to your lowest needed level of abstraction. > If your lowest level of abstraction is bird, then you'll only have > instances of the Bird class, but not instances of the Animal class. If > your generalization needs to be more specific, then you'd have instances > of the Parrot class, but not of the Bird and the Animal classes. What are you supposed to do if the appropriate level of abstraction varies at run time? I'll sometimes think "There's a peacock" or "There's a mallard duck", but at other times "That's a very elegant brown bird". The level of abstraction changes depending on the information I have about the bird. Sometimes I have enough information to classify the bird by species, sometimes by general type - I can tell the difference between a duck and a vulture, without necessarily knowing the exact species - and sometimes just by "bird" plus description. Patricia
From: Eric Sosman on 26 Jun 2010 10:42 On 6/26/2010 9:40 AM, Patricia Shanahan wrote: > Screamin Lord Byron wrote: >> On 06/26/2010 03:15 AM, Eric Sosman wrote: > ... >>> to lump a whole aviary >>> of Pollys and Snoofleses and FeatheredBastards and so on into >>> Parrot. Or, let it be said, into Bird. >> >> You will lump it according to your lowest needed level of abstraction. >> If your lowest level of abstraction is bird, then you'll only have >> instances of the Bird class, but not instances of the Animal class. If >> your generalization needs to be more specific, then you'd have instances >> of the Parrot class, but not of the Bird and the Animal classes. > > What are you supposed to do if the appropriate level of abstraction > varies at run time? > > I'll sometimes think "There's a peacock" or "There's a mallard duck", > but at other times "That's a very elegant brown bird". The level of > abstraction changes depending on the information I have about the bird. class Bird { ... } class Duck extends Bird { ... } class Mallard extends Duck { ... } class Peacock extends Bird { ... } Bird[] observed = { new Peacock("There's a peacock"), new Mallard("There's a mallard duck"), new Bird("There's a very elegant brown bird"), }; if (moreInformationBecomesAvailable()) { observed[2] = new Wren(observed[2]); } > Sometimes I have enough information to classify the bird by species, > sometimes by general type - I can tell the difference between a duck and > a vulture, without necessarily knowing the exact species - and sometimes > just by "bird" plus description. It seems to me that the choice of taxonomy is driven not by the nature of the things "out there" in the world, but by their nature in the program's model of the world. One program may find it useful to distinguish between Thrush and Swallow. Another may need to go further and distinguish Goose from Gander. Still another may just use Bird, with a single parameter describing how much damage it does when sucked into an aircraft engine. The features chosen for modeling have more to do with the nature of the model than with the true nature (whatever *that* is) of the thing modeled. -- Eric Sosman esosman(a)ieee-dot-org.invalid
From: Screamin Lord Byron on 26 Jun 2010 12:49
On 06/26/2010 05:53 PM, Arne Vajhøj wrote: > I don't think anyone is arguing against the two cases: > 1) just having a Bird class > 2) having an abstract Bird class and concrete subclasses > I think the argument is against having: > 3) instances of Bird and instances of subclasses of Bird in the > same app Exactly. > I would even say that #3 is sometimes practical, but it is not > good OOP. I'll have to agree with that. The bottom line is what Mike Schilling said in the beginning: if you need to do an exact class-check, then you should probably think again about your design. |