Article View: borland.public.jbuilder.java.language
Article #14400Re: Your Openion needed.
From: Mark Meuer
Date: Fri, 03 Sep 1999 00:00
Date: Fri, 03 Sep 1999 00:00
56 lines
2179 bytes
2179 bytes
I'm a recovering C/C++ programmer myself and am curious about this thread.
It would seem to me that the advantages of the "Single point of exit"
approach would apply as well to Java as it would to other languages. Yet,
it seems that some people here think it really doesn't. Is it that some of
you don't agree with this guideline at all, or do you think that it is good
in procedural languages and not necessary in Java?
-mark
-------
Mark Meuer
Software Engineer
Life Navigator, Inc.
mmeuer@lifenavigator.com
Matt Sweetnam <msweetnam@privitygroup.com> wrote in message
news:37CEE3D5.EFC7D06B@privitygroup.com...
> 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:
<7qor5q$imi1@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7oksdc$5pa2@forums.borland.com> <ug11txunm.fsf@sds.no> <37CEE3D5.EFC7D06B@privitygroup.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,ead9ef4a7993b06e X-Google-Attributes: gidf74b3,public From: "Mark Meuer" <mmeuer@lifenavigator.com> Subject: Re: Your Openion needed. Date: 1999/09/03 Message-ID: <7qor5q$imi1@forums.borland.com> X-Deja-AN: 520669239 References: <7oksdc$5pa2@forums.borland.com> <ug11txunm.fsf@sds.no> <37CEE3D5.EFC7D06B@privitygroup.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.language