Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: About java program. Date: Tue, 18 Jun 2013 18:56:48 -0400 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: <324f929f-772e-4004-81e1-6b454cdae794@googlegroups.com> <19wnriq53qxel.u9rt8wy6z52g.dlg@40tude.net> <1lvu4yv8sxe73$.n4o05ixuag9y.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 18 Jun 2013 22:51:55 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="24088"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/znc7rtfO5OKp53hxXvHH9" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <1lvu4yv8sxe73$.n4o05ixuag9y.dlg@40tude.net> Cancel-Lock: sha1:2AW8Wr7bicrN25ETyRBpC5QJGhI= Xref: csiph.com comp.lang.java.programmer:24459 On 6/18/2013 6:38 PM, Joerg Meier wrote: >[...] > Frankly, I'm surprised that even though it should be obvious that my code > was no more supposed to be production code for a method that simple,my > > "if (x) return true" > > faced so much more ridicule than lipskas > > "boolean var; if (x) var = true; return var", > > which is basically the same only even more verbose. Perhaps you attract more ridicule because your posts have a wider readership than lipska's. That explains my reaction, at any rate. `if (bool) return true; else return false;' does have one small advantage over `return bool;' in that it's easier to plant a breakpoint on one branch but not on the other, if a debugging session gets down to "This shouldn't be true, should it? *Should* it?" Similarly, the style of assigning a `result' variable throughout the body of a method and returning it only at the end makes it easy to trap and trace "unusual" values. In my experience these advantages are occasionally worth the extra clutter -- but only occasionally. YMMV. -- Eric Sosman esosman@comcast-dot-net.invalid