Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!s33g2000prg.googlegroups.com!not-for-mail From: lewbloch Newsgroups: comp.lang.java.programmer Subject: Re: Needs help in editing Date: Fri, 22 Jul 2011 15:52:31 -0700 (PDT) Organization: http://groups.google.com Lines: 55 Message-ID: References: <1021f122-3898-4fc9-93ed-ac1aa9403b82@q15g2000yqk.googlegroups.com> <4e03bfb7$0$23665$426a34cc@news.free.fr> <4e03c0a3$0$23665$426a34cc@news.free.fr> <4389af7c-3124-42ea-b092-54999cff42c2@z7g2000prh.googlegroups.com> <4e04e54a$0$6275$426a34cc@news.free.fr> <4e29f5f1$0$304$14726298@news.sunsite.dk> NNTP-Posting-Host: 127.6.6.6 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1311375152 14048 127.0.0.1 (22 Jul 2011 22:52:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 22 Jul 2011 22:52:32 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s33g2000prg.googlegroups.com; posting-host=127.6.6.6; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ASELCHRU X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6433 On Jul 22, 3:13=A0pm, Arne Vajh=F8j wrote: > On 6/26/2011 1:30 PM, Lew wrote: > > > > > > > > > > > A=E9ris wrote: > >> lewbloch a =E9crit : > >>> Reflection is an elephant gun for > >>> shooting fleas; simple polymorphism suffices in most cases. > > >> I totally aggree. > > >> But with this (craps) code and because constructors with different > >> prototype, reflection is unavoidable? > > > Reflection is mostly avoidable. A little light use of > > 'Class#newInstance()' with package-private builders called by a factory > > method isn't very risky and avoids the typical mad craziness of looking > > up 'Method' or 'Constructor' instances. If you're going down that latte= r > > route, leave programming to those better equipped for it. > > > If you think heavy use of reflection will fix crappy code, boy are you > > ever wrong. Shit piled on top of shit only smells worse. > > It depends a little bit about what you are doing. > > I would not want to implement a Java EE 6 server without being > allowed to use reflection. > > Even some business code can use some reflection even though in > most cases it is better to hide the reflection via some DI > framework. > > Reflection is a very useful tool and a very powerful tool. One > should just limit its use to where it is necesarry. > > A B-52 bomber is also pretty powerful if you want to engage in a war. > It is not the correct tool for getting rid of the mosquitos in the > house. > That's why I referred to "heavy use" of reflection and in the context of crappy code. I completely agree that reflection is useful when needed, but whether you say "B-52 for mosquitoes" or "elephant gun for fleas" , the message is the same. Thanks for endorsing my point. -- Lew