Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "John B. Matthews" Newsgroups: comp.lang.java.programmer Subject: Re: Programming question determining two circle's relation Date: Sun, 01 May 2011 03:10:24 -0400 Organization: The Wasteland Lines: 40 Message-ID: References: <892252a0-e31d-426b-8f47-d37c0b2ec364@17g2000prr.googlegroups.com> <511ca68f-7866-4658-9b2b-b1c0c013a030@a21g2000prj.googlegroups.com> NNTP-Posting-Host: LQJtZWzu+iKlBROuDg+IUg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3410 In article , Patricia Shanahan wrote: > On 4/30/2011 2:25 PM, John B. Matthews wrote: > > In article > > <511ca68f-7866-4658-9b2b-b1c0c013a030@a21g2000prj.googlegroups.com>, > > byhesed wrote: > > > >> On 4ø˜30¿|, ø¿»Ÿ6‡ˆ08†-, Patricia Shanahan wrote: > >>> [...] > >>> > >>> If you have a calculation you need to do a lot, why not write and > >>> test a separate method to do it, rather than writing the > >>> calculation in-line repeatedly? > >>> > >>> [...] > >> > >> I know the source code I had posted is silly. > >> I do not perform any optimization because it is just an example. > > > > I would argue that the re-factoring suggested by Patricia is an > > opportunity to reduce error, both now and in future development or > > maintenance. I know it's tempting to dismiss the work as temporary, but > > we've all seen a prototype sneak into production. > > > > I certainly proposed it as a means to the achieving correct code. > > Not taking the square root, and doing some comparisons between squares > of distances, is a performance optimization that may or may not be > useful, depending on how often the code is run. It is premature > optimization, and a very bad idea, until the code is running correctly. I see what you mean, now. I had thought some re-factoring would lend clarity, but I over-estimated the benefit. -- John B. Matthews trashgod at gmail dot com