Looking at this math is making me num...
-
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
-
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
So basically, if the number is 3 or 4 do something.
Deja View - the feeling that you've seen this post before.
-
So basically, if the number is 3 or 4 do something.
Deja View - the feeling that you've seen this post before.
-
So basically, if the number is 3 or 4 do something.
Deja View - the feeling that you've seen this post before.
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
-
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
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.
-
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
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.
-
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
"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."
-
"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."
-
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
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 anif
is reasonable. BTW: on the other handelse 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] -
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.