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, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10ad19,23963231b5359f74 X-Google-Attributes: gid10ad19,public X-Google-Thread: 101deb,23963231b5359f74 X-Google-Attributes: gid101deb,public X-Google-Thread: 103376,23963231b5359f74 X-Google-Attributes: gid103376,public X-Google-Thread: 1073c2,23963231b5359f74 X-Google-Attributes: gid1073c2,public X-Google-Thread: 10a146,23963231b5359f74 X-Google-Attributes: gid10a146,public X-Google-Thread: 107a89,23963231b5359f74 X-Google-Attributes: gid107a89,public X-Google-ArrivalTime: 2001-06-08 07:05:05 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!newsfeed.r-kom.de!feeder01.news.de.uu.net!news-1.bank.dresdner.net!not-for-mail From: James Kanze Newsgroups: comp.lang.ada,comp.lang.awk,comp.lang.clarion,comp.lang.java.programmer,comp.lang.pl1,comp.lang.vrml Subject: Re: Long names are doom ? Date: Fri, 08 Jun 2001 16:01:57 +0200 Organization: Dresdner Bank AG Message-ID: <3B20DAD5.3D3B30BA@dresdner-bank.com> References: <83WP6.3874$yc6.728572@news.xtra.co.nz> <+FWVg+noA0yk@eisner.encompasserve.org> <9fjfc4$qdv$1@news.fsu.edu> <9fjkha$re7$1@bugstomper.ihug.com.au> Reply-To: default@dresdner-bank.com NNTP-Posting-Host: ffzj09tz.bank.dresdner.net Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mozilla 4.7 [en]C-CCK-MCD drebazen10 (WinNT; I) X-Accept-Language: en,fr,de Xref: archiver1.google.com comp.lang.ada:8404 comp.lang.awk:2896 comp.lang.clarion:21436 comp.lang.java.programmer:74756 comp.lang.pl1:901 comp.lang.vrml:3639 Date: 2001-06-08T16:01:57+02:00 List-Id: Jon Skeet wrote: > Blaikie wrote: > > > Depends on the language of course, but I think it is likely that > > > this is the wrong solution. At some point, it would make sense > > > to replace the case statement with a config file and some > > > program that automatically generated the case code from the > > > config file. > > > If the language supported it, a jump table might make more sense > > > than a case statement. Again the jump table could be loaded from > > > a config file. > > well i am not sure what a jump table is, but if it were in Java > > and there were corresponding methods to each of the cases in the > > swtich, i would use a general piece of java.lang.reflection code > > to load the method based directly on the string (or turn the > > variable into the string nescessary using maybe a hashmap) > Reflection would be an *incredibly* slow way of doing that. Better > would be to create (at startup) one object for handling each case, > each implementing the same interface. Put *those* into a map of some > description, then get out the "right" object and call one of the > methods of the common interface. That's the way I generally do it, but there are exceptions. The classical example is in lexical analysis, where you use a switch with one entry per starting character. Speed is often an issue here, of course. (And in most modern systems, you'll arrange for the switch to be generated automatically, so it isn't hand written code.) Of course, the fact that there is ONE exception doesn't invalidate the general premice. -- James Kanze mailto:kanze@gabi-soft.de Conseils en informatique orient�e objet/ Beratung in objektorientierter Datenverarbeitung Ziegelh�ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627