Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!bu.edu!snorkelwacker.mit.edu!apple!usc!wuarchive!uunet!mcsun!ukc!mucs!logitek!hrc63!mrcu!paj From: paj@mrcu (Paul Johnson) Newsgroups: comp.object Subject: Re: Readability of Ada Message-ID: <913@puck.mrcu> Date: 26 Apr 91 15:25:20 GMT References: <3878@ssc-bee.ssc-vax.UUCP> <20245@alice.att.com> <1991Apr23.193715.23815@odin.diku.dk> Reply-To: paj@uk.co.gec-mrc (Paul Johnson) Organization: GEC-Marconi Research Centre, Great Baddow, UK Lines: 47 >]>Now, I want to take a heterogeneous list of shapes, including triangles, >]>circles, and squares, and I want to iterate over the list and print >]>out all of the radii. > >]Who wrote the heterogeneous-list code? The guy who supplied the shape >]classes? Of course not, because then he would have realized the need >]for a shape method to identify exactly what kind of shape it is. > >Uh huh. Precisely the point made in "Emperor Strikes Lethe"--you DON'T >have any control over the guy who writes the class hierarchy upon which >you depend. Indeed, in my example I specifically said that the class >hierarchy is delivered in binary for security/monetary reasons, so you're >at the mercy of it completely. And you just want to add a simple little >class with some additional functionality--seems reasonable to me--but >you CAN'T. [ Long article which presuposes that the way to solve this problem is via type tags ] *READ* *MY* *LIPS* ! *NO* *MORE* *TYPE* *TAGS* The original problem was to iterate over a list of generic shapes and print out the radii of those that had them. The way to do this is to keep a separate list of objects with a radius and walk down that. You do NOT start sticking in CASE statements on type tags. These are precisely the things that OO programming is supposed to avoid. Once you put in one such routine, they proliferate, and you keep having to go back to existing functions to add new cases for your new classes. Later in the article the point was made that "all" languages except C++ contain a way of finding out what type you are dealing with. I don't know about Smalltalk, but reverse assignment was included in Eiffel in order to handle situations (such as reconstituting objects from a flat file) where static type information is unavailable. It has no other purpose. If you find yourself using type tags or some similar dodge, you have done it wrong and are just storing up trouble. Now don't let me have to tell you again! :-) Paul. -- Paul Johnson | Isn't modern education wonderful: one size fits all! -------------^------------------v-------------------------v------------------- GEC-Marconi Research is not | Telex: 995016 GECRES G | Tel: +44 245 73331 responsible for my opinions. | Inet: paj@gec-mrc.co.uk | Fax: +44 245 75244