Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 30 Apr 2011 19:03:49 -0500 Date: Sat, 30 Apr 2011 17:03:48 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Programming question determining two circle's relation References: <892252a0-e31d-426b-8f47-d37c0b2ec364@17g2000prr.googlegroups.com> <511ca68f-7866-4658-9b2b-b1c0c013a030@a21g2000prj.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 31 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-0lo5ZqP6M6WIJkmvcyoEy57NFPWWL5X4I8ZaGeCSZfSrtcg45tcwjO/hZWxrEzeObCOLq528eW6zYcQ!XPZOUOZQNs1r2wslihv6oasx5v8ZB6dEH+JQYR3fS4DO/CGivZWmQpFKWcEe2lNnSywBAwI3u8Ac!BEYKdVdZoJtQkB5nwe6i8KlC3g1WkUAsanatP9JTArQ= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2604 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3392 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. Patricia