home *** CD-ROM | disk | FTP | other *** search
- 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
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Newsgroups: comp.lang.c++
- Subject: Re: member test?
- Message-ID: <721509335snx@trmphrst.demon.co.uk>
- Date: 11 Nov 92 12:15:35 GMT
- Sender: usenet@gate.demon.co.uk
- Reply-To: nikki@trmphrst.demon.co.uk
- Organization: Trumphurst Ltd.
- Lines: 37
- X-Mailer: cppnews $Revision: 1.20 $
-
- In article <1992Nov10.070124.5763@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes:
- > In article <EB.92Nov9085335@ascent.ascent.com> eb@ascent.com (Ed Barton) writes:
- > >In article <1992Nov6.081658.29693@bernina.ethz.ch> haechler@bernina.ethz.ch (Stefan Haechler) writes:
- > >
- > > How can I know which dynamic type has a variable ?
- > > ...
- > > ...
- > >The software-design answer is that you shouldn't have to know the
- > >answer to this question, and that there may be something wrong with
- > >the design if you need to ask it. If you know only that something is
- > >a pointer-to-A, you should be using only the methods and virtual
- > >functions that are part of the interface defined by class A.
- > > ...
- >
- > Come on, there are many fully reasonable and legitimate situations
- > in which one needs to know this. And C++ is almost the only OOPL
- > I know of in which you cannot ask the dynamic type of an object.
- I disagree. There are (IMHO) a very few, highly specialised cases in which
- it is NECESSARY to know the dynamic type of an object.
-
- The most convincing example I have come across is where objects are
- transferred between different invokations of a program (e.g. over
- networks, or by storing to disk and retrieving at some later time).
-
- In all such examples I have seen, additional information is also required
- (e.g some kind of type coding system for the data transfer, and some
- means of reconstructing an object of the appropriate type at the other
- end).
-
- Of course, it is often EASIER to design a system with run-time type
- identification, but I respectfully suggest that the extra effort put into
- designing without using such information will pay off in a more robust and
- maintainable system.
-
- --
- Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-