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: Mon, 17 Jun 2013 14:49:38 -0400 Organization: A noiseless patient Spider Lines: 36 Message-ID: References: <324f929f-772e-4004-81e1-6b454cdae794@googlegroups.com> <19wnriq53qxel.u9rt8wy6z52g.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 17 Jun 2013 18:44:40 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="7964"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1n09erYloUdY72y/IiI+P" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <19wnriq53qxel.u9rt8wy6z52g.dlg@40tude.net> Cancel-Lock: sha1:zMELtytAQFPE0kqlKac11skwGIA= Xref: csiph.com comp.lang.java.programmer:24440 On 6/17/2013 2:32 PM, Joerg Meier wrote: >[...] > Personally, I found your example considerably harder to read than the one > liner, as well as harder to read than what would have been my solution: > > private boolean askYesNoquestion (String str){ > if(str.equals("yes")) > return true; > > return false; > } Or, for even greater clarity: private boolean askYesNoquestion(String str) { boolean yes; boolean no; if (str != null && str.equals("yes")) { yes = true; no = false; } else if (str != null && str.equals("no")) { no = true; yes = false; } else { yes = no = false; } return (no != true && yes != false) == true; } (If we put our minds to it, I bet we can turn the one-liner into an entire class hierarchy with runtime-selected plug-in provider implementations!) -- Eric Sosman esosman@comcast-dot-net.invalid