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. Testing the obvious....

Testing the obvious....

Scheduled Pinned Locked Moved The Weird and The Wonderful
testingbeta-testing
12 Posts 10 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.
  • R Rob Grainger

    Not a new horror, nonetheless something tells me this If statement may be redundant...

    fileName = ""
    
    If Len(fileName) = 0 Then
        fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
    End If
    
    M Offline
    M Offline
    Mike Winiberg
    wrote on last edited by
    #3

    Hmmm, tricky. Give me a few hours and I'll get back to you on that one... 8)

    1 Reply Last reply
    0
    • R Rob Grainger

      Not a new horror, nonetheless something tells me this If statement may be redundant...

      fileName = ""
      
      If Len(fileName) = 0 Then
          fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
      End If
      
      B Offline
      B Offline
      Brady Kelly
      wrote on last edited by
      #4

      Well, stating the obvious, it's quite likely that, either the coder didn't want to rely on code never being inserted between the initializer and guard, or, more likely, the coder added the initializer later, probably to test the guard. Hey, you never know...

      1 Reply Last reply
      0
      • R Rob Grainger

        Not a new horror, nonetheless something tells me this If statement may be redundant...

        fileName = ""
        
        If Len(fileName) = 0 Then
            fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
        End If
        
        M Offline
        M Offline
        mbb01
        wrote on last edited by
        #5

        There may have been code between the initialiser and the if statement that has since been removed. It might actually be a better piece of coding than you think. You always have the option of inserting some more code between the two and it might stand a chance of still working. ;)

        R 1 Reply Last reply
        0
        • R Rob Grainger

          Not a new horror, nonetheless something tells me this If statement may be redundant...

          fileName = ""
          
          If Len(fileName) = 0 Then
              fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
          End If
          
          R Offline
          R Offline
          R Erasmus
          wrote on last edited by
          #6

          So the if statement is redundent... Maybe the dude has got a resentment towards some tester maybe? fileName is obviously a string which is a referenced type. If it wasn't initialized could of contained some garbage and length would of therefor been > 0. However this is not the case... It is initialised and therefor redundent.

          "Program testing can be used to show the presence of bugs, but never to show their absence." << please vote!! >>

          1 Reply Last reply
          0
          • M mbb01

            There may have been code between the initialiser and the if statement that has since been removed. It might actually be a better piece of coding than you think. You always have the option of inserting some more code between the two and it might stand a chance of still working. ;)

            R Offline
            R Offline
            R Erasmus
            wrote on last edited by
            #7

            True, I would agree with you... He is testing for null. Having it in there is better than not having it in there.

            "Program testing can be used to show the presence of bugs, but never to show their absence." << please vote!! >>

            1 Reply Last reply
            0
            • R Rob Grainger

              Not a new horror, nonetheless something tells me this If statement may be redundant...

              fileName = ""
              
              If Len(fileName) = 0 Then
                  fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
              End If
              
              H Offline
              H Offline
              Hosey
              wrote on last edited by
              #8

              I posted an example like this in the lounge a few months ago... also found ASP code like this...

              for each element in Request.form
              if request.form("specificElement") <> "" then
              someVar = request.form("specificElement")
              ...
              [do some other stuff]
              end if
              next

              It hurts both my eyes and my brain :(

              1 Reply Last reply
              0
              • R Rob Grainger

                Not a new horror, nonetheless something tells me this If statement may be redundant...

                fileName = ""
                
                If Len(fileName) = 0 Then
                    fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
                End If
                
                S Offline
                S Offline
                sjelen
                wrote on last edited by
                #9

                We do not see the scope of fileName. Maybe another thread can change it's value :)

                D 1 Reply Last reply
                0
                • S sjelen

                  We do not see the scope of fileName. Maybe another thread can change it's value :)

                  D Offline
                  D Offline
                  Dietmar Kern
                  wrote on last edited by
                  #10

                  then the code would be incorrect even with the test for zero length

                  S E 2 Replies Last reply
                  0
                  • D Dietmar Kern

                    then the code would be incorrect even with the test for zero length

                    S Offline
                    S Offline
                    sjelen
                    wrote on last edited by
                    #11

                    incorrect - yes, I'm not talking about sync-ing threads. My point was in that case code would not be "Testing the obvious..."

                    1 Reply Last reply
                    0
                    • D Dietmar Kern

                      then the code would be incorrect even with the test for zero length

                      E Offline
                      E Offline
                      ely_bob
                      wrote on last edited by
                      #12

                      :laugh: :laugh: :laugh: :laugh: .. ...

                      try
                      {
                      retry:
                      while (filename = EmptyString)
                      {
                      if(Len(fileName) == 0)
                      {
                      fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
                      }
                      }
                      }
                      catch
                      {
                      goto retry;
                      }
                      filename = "";

                      :laugh: :laugh: :laugh: :laugh: :laugh: .... just trying to see how many people will complain about this.... ;P

                      I'd blame it on the Brain farts.. But let's be honest, it really is more like a Methane factory between my ears some days then it is anything else...
                      -----
                      "The conversations he was having with himself were becoming ominous."-.. On the radio...

                      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