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. Other Discussions
  3. The Weird and The Wonderful
  4. I just made a secret GOTO

I just made a secret GOTO

Scheduled Pinned Locked Moved The Weird and The Wonderful
com
5 Posts 4 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.
  • P Offline
    P Offline
    peterchen
    wrote on last edited by
    #1

    while(true) // repeat after upgrade
    {
    thingie.Open();
    if (thingie.Stale() && YesUserReallyWantsToUpgrade())
    {
    thingie.Close();
    continue;
    }
    // ...
    break;
    }

    On the plus side, I've had secret santa's that were worse. On the down side, that would look better with a goto, which doesn't sound exactly good.

    ORDER BY what user wants

    L F 2 Replies Last reply
    0
    • P peterchen

      while(true) // repeat after upgrade
      {
      thingie.Open();
      if (thingie.Stale() && YesUserReallyWantsToUpgrade())
      {
      thingie.Close();
      continue;
      }
      // ...
      break;
      }

      On the plus side, I've had secret santa's that were worse. On the down side, that would look better with a goto, which doesn't sound exactly good.

      ORDER BY what user wants

      L Offline
      L Offline
      Lutoslaw
      wrote on last edited by
      #2

      We can hide goto[^] even better:

      bread.Open();
      try
      {
      if (bread.Stale() && Banana()) // better naming!
      {
      throw DamnUserSeeksDooom();
      }
      // ...
      }
      catch (DamnUserSeeksDooom DUST)
      {
      dust.Sweep();
      }
      finally
      {
      bread.close();
      }

      Teez javaOOP style. The more blue words the more proffesional code looks, you know. :rolleyes:

      Greetings - Jacek

      A 1 Reply Last reply
      0
      • P peterchen

        while(true) // repeat after upgrade
        {
        thingie.Open();
        if (thingie.Stale() && YesUserReallyWantsToUpgrade())
        {
        thingie.Close();
        continue;
        }
        // ...
        break;
        }

        On the plus side, I've had secret santa's that were worse. On the down side, that would look better with a goto, which doesn't sound exactly good.

        ORDER BY what user wants

        F Offline
        F Offline
        Freak30
        wrote on last edited by
        #3

        So the thingie refuses to upgrade, because it does nothing as long as the user wants it to upgrade? What does it do if the user doesn't want it to upgrade? Does it upgrade in this case?

        The good thing about pessimism is, that you are always either right or pleasently surprised.

        P 1 Reply Last reply
        0
        • L Lutoslaw

          We can hide goto[^] even better:

          bread.Open();
          try
          {
          if (bread.Stale() && Banana()) // better naming!
          {
          throw DamnUserSeeksDooom();
          }
          // ...
          }
          catch (DamnUserSeeksDooom DUST)
          {
          dust.Sweep();
          }
          finally
          {
          bread.close();
          }

          Teez javaOOP style. The more blue words the more proffesional code looks, you know. :rolleyes:

          Greetings - Jacek

          A Offline
          A Offline
          Argonia
          wrote on last edited by
          #4

          Jacek Gajek wrote:

          catch (DamnUserSeeksDooom DUST) { dust.Sweep(); }

          i guess you swept your DUST before the actual call and it became smaler dust :D P.S sleeping only 5 hours isn't working well with my spelling skills.

          Microsoft ... the only place where VARIANT_TRUE != true

          1 Reply Last reply
          0
          • F Freak30

            So the thingie refuses to upgrade, because it does nothing as long as the user wants it to upgrade? What does it do if the user doesn't want it to upgrade? Does it upgrade in this case?

            The good thing about pessimism is, that you are always either right or pleasently surprised.

            P Offline
            P Offline
            peterchen
            wrote on last edited by
            #5

            That's a bit mroe complex than this simplified example of course (surprisingly, I don't have variales named "thingie" in there) - depending on the forma,t it's read only access or no access at all, indeed. Since the conversion runs in a separate process, I'm in the middle of a transaction, and I have to be careful to throw more milliseconds into that piece of code, tat "close, convert and retry" seems to be the best approach. Alternatively, I thought of an inner function that returns either the newly initialized session, or information about how to upgrade, but that code doesn#t look much better either.

            ORDER BY what user wants

            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