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. Looking at this math is making me num...

Looking at this math is making me num...

Scheduled Pinned Locked Moved The Weird and The Wonderful
questionlounge
10 Posts 7 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.
  • A Offline
    A Offline
    AeonBlue
    wrote on last edited by
    #1

    So, I'm sure this has happened to everyone but I'm pouring through a section of v1.0 of a program I am updating. There's a section where some decent algebra is involved and all of the variables used were num1, num2, num3 etc. down the line. This is in several pages of code and it goes up to num26, but at least they are all declared locally. There is no consistency between in-line if statements and general if statements; they are used intermittently and in no semblance of order whatsoever. In two separate places, the math that is used conflicts with the documentation that was provided so now I have to figure out which is correct so I can rewrite this correctly and accurately. They had code for a dropdown box that said

    if (NumOfConveyors >= 3) && (NumOfConveyors <= 4)
    //do stuff

    ...so...if your dropdown box only gives me the option of whole numbers, why even check to see if there will be a number in between 3 and 4? You are never going to have .25 of a conveyor. :doh: And there's an if instead of an elseif in a block of code which sets one of the num variables to a totally wrong number. Good times finding that one out. ;)

    "The shortest distance between two points is under construction" -Noelie ALtito

    P C 2 Replies Last reply
    0
    • A AeonBlue

      So, I'm sure this has happened to everyone but I'm pouring through a section of v1.0 of a program I am updating. There's a section where some decent algebra is involved and all of the variables used were num1, num2, num3 etc. down the line. This is in several pages of code and it goes up to num26, but at least they are all declared locally. There is no consistency between in-line if statements and general if statements; they are used intermittently and in no semblance of order whatsoever. In two separate places, the math that is used conflicts with the documentation that was provided so now I have to figure out which is correct so I can rewrite this correctly and accurately. They had code for a dropdown box that said

      if (NumOfConveyors >= 3) && (NumOfConveyors <= 4)
      //do stuff

      ...so...if your dropdown box only gives me the option of whole numbers, why even check to see if there will be a number in between 3 and 4? You are never going to have .25 of a conveyor. :doh: And there's an if instead of an elseif in a block of code which sets one of the num variables to a totally wrong number. Good times finding that one out. ;)

      "The shortest distance between two points is under construction" -Noelie ALtito

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      So basically, if the number is 3 or 4 do something.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      A P 2 Replies Last reply
      0
      • P Pete OHanlon

        So basically, if the number is 3 or 4 do something.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        A Offline
        A Offline
        AeonBlue
        wrote on last edited by
        #3

        Yeah, the check to see if something is between them is pointless. Although it's not such a big deal, it is a little annoying to look at.

        "The shortest distance between two points is under construction" -Noelie ALtito

        D CPalliniC 2 Replies Last reply
        0
        • P Pete OHanlon

          So basically, if the number is 3 or 4 do something.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

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

          Pete O'Hanlon wrote:

          if the number is 3 or 4 do something.

          I believe the terminology used was "do stuff". ;P Regards, --Perspx

          "The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia Introduction to Object-Oriented JavaScript

          P 1 Reply Last reply
          0
          • P Perspx

            Pete O'Hanlon wrote:

            if the number is 3 or 4 do something.

            I believe the terminology used was "do stuff". ;P Regards, --Perspx

            "The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia Introduction to Object-Oriented JavaScript

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            Perspx wrote:

            I believe the terminology used was "do stuff".

            I'm sorry. I forget the technical stuff.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            1 Reply Last reply
            0
            • A AeonBlue

              Yeah, the check to see if something is between them is pointless. Although it's not such a big deal, it is a little annoying to look at.

              "The shortest distance between two points is under construction" -Noelie ALtito

              D Offline
              D Offline
              dighn
              wrote on last edited by
              #6

              I don't think that's bad at all. It's written in a general way so if the bounds change, the logic doesn't have to. Maybe the bounds used to be larger, but somewhere along the way they were changed so now it looks a bit funny. I would write it that way myself because we deal with changing parameters all the time. In fact I'd make 3 and 4 constants.

              B 1 Reply Last reply
              0
              • A AeonBlue

                So, I'm sure this has happened to everyone but I'm pouring through a section of v1.0 of a program I am updating. There's a section where some decent algebra is involved and all of the variables used were num1, num2, num3 etc. down the line. This is in several pages of code and it goes up to num26, but at least they are all declared locally. There is no consistency between in-line if statements and general if statements; they are used intermittently and in no semblance of order whatsoever. In two separate places, the math that is used conflicts with the documentation that was provided so now I have to figure out which is correct so I can rewrite this correctly and accurately. They had code for a dropdown box that said

                if (NumOfConveyors >= 3) && (NumOfConveyors <= 4)
                //do stuff

                ...so...if your dropdown box only gives me the option of whole numbers, why even check to see if there will be a number in between 3 and 4? You are never going to have .25 of a conveyor. :doh: And there's an if instead of an elseif in a block of code which sets one of the num variables to a totally wrong number. Good times finding that one out. ;)

                "The shortest distance between two points is under construction" -Noelie ALtito

                C Offline
                C Offline
                ClementsDan
                wrote on last edited by
                #7

                "all of the variables used were num1, num2, num3 etc. down the line. This is in several pages of code and it goes up to num26," They probably started off calling them a, b, c, ..., z, until learning that "you shouldn't use 1-letter variable names."

                A 1 Reply Last reply
                0
                • C ClementsDan

                  "all of the variables used were num1, num2, num3 etc. down the line. This is in several pages of code and it goes up to num26," They probably started off calling them a, b, c, ..., z, until learning that "you shouldn't use 1-letter variable names."

                  A Offline
                  A Offline
                  AeonBlue
                  wrote on last edited by
                  #8

                  haha, It just occured to me that there are 26 variables and 26 letters in the alphabet. That's too ironic to ignor. :laugh:

                  "The shortest distance between two points is under construction" -Noelie ALtito

                  1 Reply Last reply
                  0
                  • A AeonBlue

                    Yeah, the check to see if something is between them is pointless. Although it's not such a big deal, it is a little annoying to look at.

                    "The shortest distance between two points is under construction" -Noelie ALtito

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #9

                    AeonBlue wrote:

                    Yeah, the check to see if something is between them is pointless

                    That's not true. A switch is more elegant (I think) but such an if is reasonable. BTW: on the other hand else if is a must, after the above statement. :)

                    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
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    • D dighn

                      I don't think that's bad at all. It's written in a general way so if the bounds change, the logic doesn't have to. Maybe the bounds used to be larger, but somewhere along the way they were changed so now it looks a bit funny. I would write it that way myself because we deal with changing parameters all the time. In fact I'd make 3 and 4 constants.

                      B Offline
                      B Offline
                      BillW33
                      wrote on last edited by
                      #10

                      I totally agree. I have had requirements change far more often than not. Even for things that I was originally told that it would never change. So I always write things in such a way as to allow for easy changes in the future. Bill W

                      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