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. Range-Checking (not)

Range-Checking (not)

Scheduled Pinned Locked Moved The Weird and The Wonderful
help
6 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.
  • R Offline
    R Offline
    Rob Grainger
    wrote on last edited by
    #1

    I kid you not - genuinely found in production code. Has raised a smile or two in our office.

    If flag < 1 And flag > 3 Then Exit Function
    

    That's actually not the worst problem with the code, but definitely the funniest.

    A 1 Reply Last reply
    0
    • R Rob Grainger

      I kid you not - genuinely found in production code. Has raised a smile or two in our office.

      If flag < 1 And flag > 3 Then Exit Function
      

      That's actually not the worst problem with the code, but definitely the funniest.

      A Offline
      A Offline
      AspDotNetDev
      wrote on last edited by
      #2

      Methinks the guy who works for my company has a sibling who works for yours. :rolleyes: Though, if "flag" is a delayed computation with overridden operators, that could actually turn out to be true (e.g., square root of 100 is both positive and negative 10). ;P

      [Forum Guidelines]

      D R 2 Replies Last reply
      0
      • A AspDotNetDev

        Methinks the guy who works for my company has a sibling who works for yours. :rolleyes: Though, if "flag" is a delayed computation with overridden operators, that could actually turn out to be true (e.g., square root of 100 is both positive and negative 10). ;P

        [Forum Guidelines]

        D Offline
        D Offline
        Dalek Dave
        wrote on last edited by
        #3

        It is still bad though!

        ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

        A 1 Reply Last reply
        0
        • D Dalek Dave

          It is still bad though!

          ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

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

          Your post the other day was part of my inspiration for my point about the square root of a number... so you're partly to blame for my silliness! :)

          [Forum Guidelines]

          1 Reply Last reply
          0
          • A AspDotNetDev

            Methinks the guy who works for my company has a sibling who works for yours. :rolleyes: Though, if "flag" is a delayed computation with overridden operators, that could actually turn out to be true (e.g., square root of 100 is both positive and negative 10). ;P

            [Forum Guidelines]

            R Offline
            R Offline
            Rob Grainger
            wrote on last edited by
            #5

            That was one of the reasons I immediately posted it - the coincidence of seeing yours so recently. I almost wish there was something clever like that going on, but no, flag is declared as an Integer. As DD pointed out though, even if that was the case its still a horror. I'm coming round to the view that operator overloading maybe a bad idea because of the potential for abuses like this. Although I note that D provides a better implementation, where defining opCmp covers the whole family of <, <= etc. preventing abuses like that (to an extent).

            R 1 Reply Last reply
            0
            • R Rob Grainger

              That was one of the reasons I immediately posted it - the coincidence of seeing yours so recently. I almost wish there was something clever like that going on, but no, flag is declared as an Integer. As DD pointed out though, even if that was the case its still a horror. I'm coming round to the view that operator overloading maybe a bad idea because of the potential for abuses like this. Although I note that D provides a better implementation, where defining opCmp covers the whole family of <, <= etc. preventing abuses like that (to an extent).

              R Offline
              R Offline
              richard_k
              wrote on last edited by
              #6

              I unfortunately must disagree.. no amount of language feature or design constraint can save you from a programmer lacking in programming skills. The only solution for THAT problem is good code review and a team willing to point out ways to improve (and enforce them) to the souls who are in this occupation but shouldn't be. And.. your original post is hilarious and sad at the same time. For the same reasons.

              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