home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16174 < prev    next >
Encoding:
Text File  |  1992-11-12  |  2.2 KB  |  49 lines

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