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. Must love to run twice

Must love to run twice

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpdatabase
5 Posts 5 Posters 1 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.
  • C Offline
    C Offline
    che3358
    wrote on last edited by
    #1

    The following code I found some developer used very often. I just wonder might he loves to run getStatus twice to make sure his code executed perfect. if(GetStatus(id) != "") string status = GetStatus(id); private string GetStatus(int recordId) { string s = ""; //First, use ADO.NET to get the Status of this recordId //Then, assign the status to a string. if(//Check to make sure there is data and not DB null) s = //The data; //Finally, return the string return s; }

    C V P J 4 Replies Last reply
    0
    • C che3358

      The following code I found some developer used very often. I just wonder might he loves to run getStatus twice to make sure his code executed perfect. if(GetStatus(id) != "") string status = GetStatus(id); private string GetStatus(int recordId) { string s = ""; //First, use ADO.NET to get the Status of this recordId //Then, assign the status to a string. if(//Check to make sure there is data and not DB null) s = //The data; //Finally, return the string return s; }

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Possibly he went from the VB realm. :-D

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      1 Reply Last reply
      0
      • C che3358

        The following code I found some developer used very often. I just wonder might he loves to run getStatus twice to make sure his code executed perfect. if(GetStatus(id) != "") string status = GetStatus(id); private string GetStatus(int recordId) { string s = ""; //First, use ADO.NET to get the Status of this recordId //Then, assign the status to a string. if(//Check to make sure there is data and not DB null) s = //The data; //Finally, return the string return s; }

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        It is an ambitious way to save a memory variable that people succumb to a bad performance of an application by calling a lengthier function twice or more.

        Vasudevan Deepak Kumar Personal Homepage
        Tech Gossips
        All the world's a stage, And all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts... --William Shakespeare

        1 Reply Last reply
        0
        • C che3358

          The following code I found some developer used very often. I just wonder might he loves to run getStatus twice to make sure his code executed perfect. if(GetStatus(id) != "") string status = GetStatus(id); private string GetStatus(int recordId) { string s = ""; //First, use ADO.NET to get the Status of this recordId //Then, assign the status to a string. if(//Check to make sure there is data and not DB null) s = //The data; //Finally, return the string return s; }

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

          If it's worth getting, it's worth getting twice. :-D

          1 Reply Last reply
          0
          • C che3358

            The following code I found some developer used very often. I just wonder might he loves to run getStatus twice to make sure his code executed perfect. if(GetStatus(id) != "") string status = GetStatus(id); private string GetStatus(int recordId) { string s = ""; //First, use ADO.NET to get the Status of this recordId //Then, assign the status to a string. if(//Check to make sure there is data and not DB null) s = //The data; //Finally, return the string return s; }

            J Offline
            J Offline
            Jonathan C Dickinson
            wrote on last edited by
            #5

            That is a race just waiting to happen!!! In C# I try not to use an 'is' followed by a cast for the same reason. The following code reads so much nicer:

            Bar bar = o as Bar;
            if(bar != null)
            {
            }

            than this:

            if(o is Bar && !object.ReferenceEquals(o, null))
            {
            }

            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