Article View: borland.public.jbuilder.java.language
Article #14477Re: Your Openion needed.
From: Matt Sweetnam
Date: Thu, 02 Sep 1999 00:00
Date: Thu, 02 Sep 1999 00:00
38 lines
1451 bytes
1451 bytes
I sense an ex-"C" developer :o)
Tor Iver Wilhelmsen wrote:
> "Dillan Fernando" <dillan@geocities.com> writes:
>
> > public boolean dummy()
> > { for(a=0;a<x;a++)
> > { if (a==b) return true
> > }
> > return false;
> > }
>
> Procedural programmers will balk at it and mumble something about
> "single exit point": to please them, rewrite it like this:
>
> public boolean dummy() {
> boolean retVal = false;
> loop: for (int a = 0; a < x; a++) {
> if (a == b) {
> retVal = true;
> break loop;
> }
> }
> return retVal;
> }
>
> Note: The "loop" label here is redundant, and only there for
> readability purposes.
>
> (I assume your sample code was just an illiustration: The method below
> is a much faster version:
>
> public void dummy() {
> return ((b >= 0) && (b < x));
> }
>
> )
Technical Details
Message-ID:
<37CEE3D5.EFC7D06B@privitygroup.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7oksdc$5pa2@forums.borland.com> <ug11txunm.fsf@sds.no>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,ead9ef4a7993b06e X-Google-Attributes: gidf74b3,public From: Matt Sweetnam <msweetnam@privitygroup.com> Subject: Re: Your Openion needed. Date: 1999/09/02 Message-ID: <37CEE3D5.EFC7D06B@privitygroup.com> X-Deja-AN: 520330745 Content-Transfer-Encoding: 7bit References: <7oksdc$5pa2@forums.borland.com> <ug11txunm.fsf@sds.no> Content-Type: text/plain; charset=us-ascii Organization: Privity Group, LLC Mime-Version: 1.0 Reply-To: msweetnam@privitygroup.com Newsgroups: borland.public.jbuilder.java.language