From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,CTE_8BIT_MISMATCH, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public From: Del Archer Subject: Re: OO, C++, and something much better! Date: 1997/01/29 Message-ID: <32EF775C.482D@netron.com>#1/1 X-Deja-AN: 213001310 references: <5bphq4$5js@mulga.cs.mu.OZ.AU> <32E05FAF.47BA@concentric.net> <5buodl$bci@boursy.news.erols.com> <32E2FEC7.2F7B@concentric.net> <6PE5zLpF3RB@herold.franken.de> <32E8DC1C.4871@rase.com> content-type: text/plain; charset=iso-8859-1 organization: Netron, Inc. mime-version: 1.0 newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.object x-mailer: Mozilla 2.0 (WinNT; I) Date: 1997-01-29T00:00:00+00:00 List-Id: Robert C. Martin wrote: > > ... > > In fact it should be an OO sin to ask > > the type, because, in theory, we don�t want to get intimate with objects > > we are interacting apart from their interface. > > We typically don't have to ask the type of an object. In ST, the language > will do the asking for us at run time. In C++ the compiler has done it > at compile time. > > However, there are times both in ST and C++ where we are given an object > of unknown type and we do not want to send that object a message until > we *know* it can deal with it. Thus in ST we use 'respondsTo' and in > C++ we use 'dynamic_cast'. Both of these are essentially run time type > checks that can be applied by the programmer. I really question the use of 'dynamic_cast'; it makes it difficult to follow the open/closed principle. If a function or method requires a specific type, it should only accept objects of that type. Del.