Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Class.forName().newInstance() vs new Date: Sun, 12 Jun 2011 18:10:13 +0200 Lines: 26 Message-ID: <95k6n5Fpf9U1@mid.individual.net> References: <95ho4qFd7cU1@mid.individual.net> <95jod7FbdbU1@mid.individual.net> <1NGdnZX1kJp-VWnQnZ2dnUVZ_oGdnZ2d@earthlink.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Tq6/vBDk1sOTbOioFnkozgFwzKa5UVDQuQ1tWwKUAw2zmH1gY= Cancel-Lock: sha1:0PABu7yhGnTCxUh5QyAZQloMwJs= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: <1NGdnZX1kJp-VWnQnZ2dnUVZ_oGdnZ2d@earthlink.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5241 On 06/12/2011 04:10 PM, Patricia Shanahan wrote: > On 6/12/2011 5:05 AM, Robert Klemme wrote: > ... >> Thanks for hinting at this detail, Patricia! Performance of this piece >> of code can vary dramatically with configured class / handler name. That >> adds a level of complication which might make tracking issues harder >> ("It was so fast in our lab, now on production it's awfully slow."). > ... > > Is there really any program that instantiates so many database managers > that the difference between newInstance and constructor, and the > pipeline reloads related to conditional branches, become measurable? Only OP knows. That's why I also suggested to go with Class.forName() and only pick a different solution if there really was a performance issue. > I was concerned about the testing issues. Suppose some future changes > introduce a bug in the fall through path. In order to catch that bug, > there would have to be at least one test that instantiates a database > manager other than the ones that are being handled specifically. Another bad effect from complexity in the implementation... Cheers robert