home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16191 < prev    next >
Encoding:
Internet Message Format  |  1992-11-13  |  2.3 KB

  1. Path: sparky!uunet!know!cass.ma02.bull.com!mips2!news.bbn.com!usc!zaphod.mps.ohio-state.edu!rpi!uwm.edu!linac!convex!news.utdallas.edu!corpgate!bnrgate!bnr.co.uk!pipex!demon!trmphrst.demon.co.uk!nikki
  2. From: nikki@trmphrst.demon.co.uk (Nikki Locke)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: member test?
  5. Message-ID: <721509335snx@trmphrst.demon.co.uk>
  6. Date: 11 Nov 92 12:15:35 GMT
  7. Sender: usenet@gate.demon.co.uk
  8. Reply-To: nikki@trmphrst.demon.co.uk
  9. Organization: Trumphurst Ltd.
  10. Lines: 37
  11. X-Mailer: cppnews $Revision: 1.20 $
  12.  
  13. In article <1992Nov10.070124.5763@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes:
  14. > In article <EB.92Nov9085335@ascent.ascent.com> eb@ascent.com (Ed Barton) writes:
  15. > >In article <1992Nov6.081658.29693@bernina.ethz.ch> haechler@bernina.ethz.ch (Stefan Haechler) writes:
  16. > >
  17. > >   How can I know which dynamic type has a variable ?
  18. > > ...
  19. > > ...
  20. > >The software-design answer is that you shouldn't have to know the
  21. > >answer to this question, and that there may be something wrong with
  22. > >the design if you need to ask it.  If you know only that something is
  23. > >a pointer-to-A, you should be using only the methods and virtual
  24. > >functions that are part of the interface defined by class A.
  25. > > ...
  26. > Come on, there are many fully reasonable and legitimate situations
  27. > in which one needs to know this.  And C++ is almost the only OOPL
  28. > I know of in which you cannot ask the dynamic type of an object.
  29. I disagree. There are (IMHO) a very few, highly specialised cases in which
  30. it is NECESSARY to know the dynamic type of an object. 
  31.  
  32. The most convincing example I have come across is where objects are
  33. transferred between different invokations of a program (e.g. over
  34. networks, or by storing to disk and retrieving at some later time). 
  35.  
  36. In all such examples I have seen, additional information is also required
  37. (e.g some kind of type coding system for the data transfer, and some
  38. means of reconstructing an object of the appropriate type at the other
  39. end). 
  40.  
  41. Of course, it is often EASIER to design a system with run-time type 
  42. identification, but I respectfully suggest that the extra effort put into 
  43. designing without using such information will pay off in a more robust and
  44. maintainable system.
  45.  
  46. -- 
  47. Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
  48. trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
  49.