Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Do you even 'break' bro?!

Do you even 'break' bro?!

Scheduled Pinned Locked Moved The Lounge
htmltutorialquestion
23 Posts 16 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jim lahey

    Had I listened to college and university tutors in in 2001 I'd have learnt COBOL as "nothing is as good for manipulating text files".

    G Offline
    G Offline
    Gary Wheeler
    wrote on last edited by
    #21

    jim lahey wrote:

    COBOL as "nothing is as good for manipulating text files".

    I just everted my upper gastrointestinal tract. The ejecta (formerly my lunch) achieved an appreciable fraction of c[^] as it punched through the roof of our building.

    Software Zen: delete this;

    1 Reply Last reply
    0
    • P PIEBALDconsult

      Breaking out of a for loop is a code smell. (What's presented is even worse.) Maybe you don't want a for loop at all. Or, quite possibly, you just need another condition. for ( int i = 0 ; i < MaxCols && i < dr.FieldCount ; i++ )

      Y Offline
      Y Offline
      Yuriy Loginov
      wrote on last edited by
      #22

      I personally prefer using the method you suggested as it is the cleanest looking and preserves the loop invariant. Breaking half way through the loop means you don't properly finish the iteration and raises the question of why did you actually start the next iteration if there was no need to do it. Its like going to the store to get a loaf of bread and then realizing half way that you already have bread at home and then turning back

      1 Reply Last reply
      0
      • B BobJanova

        Conditions in the for loop itself are much less clear, to me at least. People are used to seeing a 'standard' loop and might well miss that entirely.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #23

        BobJanova wrote:

        People are used to seeing a 'standard' loop

        Show them more variety and they'll improve.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups