Re: break statement
From: andrea catto' (acatto_at_dataflight.com)
Date: 05/06/04
- Next message: M K: "RE: Rolling my own Install w/ MSDE"
- Previous message: Christopher Kimbell: "Re: .NET Compatibility"
- In reply to: Mark Broadbent: "Re: break statement"
- Next in thread: Martin Robins: "Re: break statement"
- Reply: Martin Robins: "Re: break statement"
- Reply: Mark Broadbent: "Re: break statement"
- Reply: Daniel O'Connell [C# MVP]: "Re: break statement"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 6 May 2004 10:44:38 -0700
AHHHHHHHHHHHHHH
NO GOTO PLEASE !!!!!!!!
It is possible............ EVERY GOOD PROGRAMMED WOULD NEVER USE GOTOS....
I used gotos in gwbasic in the msdos days, !!!!!!!! aweful, I used
gotos/jmps in assembly back then.......
in assembly only they are necessary.......
in C they are provided and yet they make the code flow hard to deal with and
dont achieve things any better then using while/loops/fors....
just refer to what Gabriele G. Ponti first wrote, use beark; to get off the
inner loop and a flag to get off the outer one or yet anothe break.
"Mark Broadbent" <no-spam-please@no-spam-please.com> wrote in message
news:OckOl54MEHA.2540@TK2MSFTNGP10.phx.gbl...
> whilst I am no expert, let me make a few comments.
> You could use the goto statement (with a label to jump to) however this is
> usually necessary when the code is bad.
>
> From your code snippet it is very hard to see exactly what you are trying
to
> do but the chances are you could do a secondary && test within the while
> loop -either moving the if statement test itself, or if that is not
possible
> setting a boolean flag
> e.g.
>
> bool loopFlag = true;
> while (intCurCategory < intTotalCategories && loopFlag)
> {
> for (intPageIter = 0;intPageIter< ITEMS_PER_PAGE;intPageIter++)
> {
> if (intPagesDisplayed>ITEMS_PER_PAGE)
> loopFlag = false;
> break; //this will break the for loop
> intPagesDisplayed++
> }
> }
>
> The other thing that strikes me about the code is the god awful naming of
> the integers. Ive been banging on for a while in the CSharp newsgroup
about
> the lack of a firm standard when naming private variables , controls etc.
> And I intend to put this right myself sometime because it's something that
I
> believe slows down development time cos you are constantly thinking "what
> shall I call this". I think the general consensus is that for private
> variables you should name them in Hungarian format (as you did) , but you
> dont need the "int" in a type safe environment this is extreme overkill
in
> my opinion (plus is confusing to the eye when a variable declaration could
> be "int variableName = value", also the names should be functionally
> descriptive (as you did) rather than abbreviated rubbish.
> For my form controls however I am currently of the opinion to prefix those
> (a la VB format) since it makes my life easier finding them using
> intellisense however I have had one expert tell me he doesnt do this
either!
>
> I hope some of this helps! Good luck.
>
> --
>
> Br,
> Mark Broadbent
> mcdba , mcse+i
> =============
> "Patrick" <patl@reply.newsgroup.msn.com> wrote in message
> news:eFqU8i4MEHA.2976@TK2MSFTNGP10.phx.gbl...
> > How could I break out of the while loop within the for/if loop below
> >
> > while (intCurCategory < intTotalCategories)
> > {
> > for (intPageIter = 0;intPageIter< ITEMS_PER_PAGE;intPageIter++)
> > {
> > if (intPagesDisplayed>ITEMS_PER_PAGE)
> > break; //trying to break out of the while loop here!
> > intPagesDisplayed++
> > }
> >
> > }
> >
> >
>
>
- Next message: M K: "RE: Rolling my own Install w/ MSDE"
- Previous message: Christopher Kimbell: "Re: .NET Compatibility"
- In reply to: Mark Broadbent: "Re: break statement"
- Next in thread: Martin Robins: "Re: break statement"
- Reply: Martin Robins: "Re: break statement"
- Reply: Mark Broadbent: "Re: break statement"
- Reply: Daniel O'Connell [C# MVP]: "Re: break statement"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|