home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Discriminating Variant Records Without switch() ??
- Message-ID: <1992Nov12.223735.1386@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <BAB.92Nov10073324@se39.wg2.waii.com> <1992Nov10.181529.2711@bmerh85.bnr.ca> <BAB.92Nov11075454@se39.wg2.waii.com>
- Date: Thu, 12 Nov 1992 22:37:35 GMT
- Lines: 36
-
- In article <BAB.92Nov11075454@se39.wg2.waii.com> bab@se39.wg2.waii.com (Brian Button) writes:
- >The point I'm trying to make is that there is no common set of
- >operations which may be performed on these arbitrary objects.
- >
- >Since the set of operations is not common, we need to know the type of the
- >object before proceeding with processing. Have we painted ourselves
- >into a corner? It seems that we need a switch() to do this, but in a
- >proper OOP design, it shouldn't be necessary.
- >
-
- Yes, it should be necessary. To me the implications of
- a common base with arbitrary derived classes are that there is indeed
- a single set of common operations that are known statically.
- Then polymorphism allows this homogenous interface to be used
- to access (via virtual functions) different derived objects.
-
- In the case of many unrelated classes one cannot use
- polymorphism. To access each object you must know its type
- statically, and the switch is the only way to do this, you must
- select physically different code for processing each object,
- and the number of said objects must be known and fixed
- and embodied in separate physical code.
-
- The key problem here is to have an arbitrary set of
- application programs P1, P2 .... each with a finite and fixed
- set of classes interfacing with a single server which can store
- arbitrary objects without losing the type information.
-
- One way to do that is to set up a global registry.
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-