home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.oop.misc
- Path: sparky!uunet!destroyer!gumby!kzoo!k044477
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Subject: Re: The Member Function: Spawn Of Satan?
- Message-ID: <1992Dec13.161514.25723@hobbes.kzoo.edu>
- Summary: member(member, Satans_spawn)?
- Organization: Kalamazoo College
- References: <1992Dec13.144549.24447@reed.edu>
- Date: Sun, 13 Dec 1992 16:15:14 GMT
- Lines: 47
-
- orpheus@reed.edu (P. Hawthorne) writes:
- >It seems un-structured. What would Djikstra say?
-
- I find myself using member() in the TCL for three chief purposes:
-
- 1] ASSERTs. It's handy to make sure something is what you expect.
- 2] In CCollaborators' ProviderChanged() method, testing whether the
- provider that changed is of a certain type. (For non-TCLers,
- CCollaborator is a class whose instances can DependUpon() each other;
- whenever a CCollaborator calls BroadcastChange(), all itsDependents
- get their ProviderChanged() method called. Very handy, but to design a
- flexible system, a CCollaborator has to expect to get lots of unwanted
- ProviderChanged() messages.)
- 3] In methods that, I suspect, would be called "friend" under C++.
- Think C doesn't give you a way to link a bunch of classes together and
- say "only these classes are friends of mine, and only my friends can
- call the following methods." (Is that essentially what C++ does?)
- So you have to fake it with run-time checking on your own.
-
- >When I use it...I worry that perhaps a seriously
- >abstract class variable could formalize whatever notions are at work. Or I
- >think that it is a kludge so that I can put off a total overhaul until I
- >figure out how to work in the exceptional classes.
-
- If you write, for example,
-
- void CEatingObject::eatObject(CFoodObject *theFoodObj)
- {
- if (member(theFoodObj, CBanana)) gobbleBanana();
- else if (member(theFoodObj, CCookie)) munchCookie();
- else if (member(theFoodObj, CSquid)) slurpSquid();
- }
-
- ...then you're misusing member(). (In this case, the eating method
- should go into CFoodObject, not CEatingObject, and should be overridden
- by all those subclasses.)
-
- If Think C's lack of multiple inheritence forces you to construct a dual
- class hierarchy, I can see having to misuse member(), as a consequence.
-
- But otherwise, unless you're doing something like CEatingObject, I
- wouldn't worry about it.
- --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- "Apple developers will still have access to System 7.1 through the
- monthly Developer CD series, but they may use it only for testing
- and development purposes." - AppleDirect, Nov/Dec 92
-