|
There were people here who would call that variable ip. It drove me crazy until I eradicated all traces of that nonsense.
|
|
|
|
|
|
BillW33 wrote: You will save a lot of time only typing 2 or 3 letter variable names instead of those long names.
And here I thought if you use shorter variable names, the program runs faster!
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Thanks. I'm now having flashbacks to GW-BASIC.
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
You tell me... this code sucks so much I wrote several VB6 lines inside C++, not kidding!
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Reminds me of my first foray into Fortran IV. Then, we used computer cards. We were only allowed six characters for variable names. Then, it was all in CAPS.
|
|
|
|
|
Sounds like a bunch of college students to me. They need refinement. But, you get what you pay for.
|
|
|
|
|
Do you get paid by the line of code?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Sadly not. I would have made a million in the first two weeks and then resigned if that was the case.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Well, seeing that you do not like switch statements to begin with, they have already failed, throwing the 4 and 5 in is just overkill.
BTW, I love how they are checking str if it is not 5 in a case statement where str = 4 . Of course it is not 5.
Edit: I just realized your title is saying what I just said. I really need to take a nap.
|
|
|
|
|
Slacker007 wrote: hey are checking str if it is not 5 in a case statement where str = 4 . Of course it is not 5.
But it might be next week!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Was it originally a set of nested if and they just missed that one?
|
|
|
|
|
MarkTJohnson wrote: Was it originally a set of nested if and they just missed that one?
I have no idea, and I didn't want to look through the TFS change history to find out.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
If that is Java...then also you can't compare strings that way! fundamental knowledge.
|
|
|
|
|
I think that
if (itIsRainin == true)
is just as bad.
|
|
|
|
|
Unless you're in California. WE WANT RAIN!
|
|
|
|
|
|
Marc Clifton wrote: Ah, the joys of outsourcing with no code reviews. Combined, perhaps, with last minute changes, or unthinking copy/cut and paste, failing to step-through debug or sheer incompetence, or all of the above.
It is smdh funny, though.
Cheers,
Mike Fidler
"I intend to live forever - so far, so good." Steven Wright
"I almost had a psychic girlfriend but she left me before we met." Also Steven Wright
"I'm addicted to placebos. I could quit, but it wouldn't matter." Steven Wright yet again.
|
|
|
|
|
Better said - better done[^]
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
That is one sick puppy.
The person should be found, bound and brought out for public humiliation immediately.
We had something like the following in legacy code:
for (x = 0; x <= 20;x++){
unknownVariable = x;
}
unknownVariable = 55;
That brings up so many questions. Was the dev trying to slow something down?
What is unknownVariable? Why did dev set it to the specific value of 55?
arghgghgghg!!!!
|
|
|
|
|
Hey now, that could actually be a valid check!
public class Stringy
{
private string Value { get; set; }
public Stringy(string value)
{
Value = value;
}
public static implicit operator string(Stringy s)
{
string value = s.Value;
if (s.Value == "4") s.Value = "5";
return value;
}
}
Which lets you write code like this:
var str = new Stringy("4");
if (str == "4" && str == "5")
Console.WriteLine("LOL");
Which will, of course, print LOL to the console.
Though I imagine you'd only do something like this if you really, really hate your co-workers.
modified 25-Oct-18 11:17am.
|
|
|
|
|
|
Aren't you a consultant / contractor? And an experienced one at that?
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
|
It's a long convoluted story about how I finally wound up on the following code (below).
It all started with a request from a friend:
naive friend "Can't you make a device for me that analyzes tones (frequencies) and turns them into MIDI and outputs them to my computer so I can play the guitar and have it turned into MIDI? Should be easy right?"
Me: Everything should be easy.
Well, there was a official arduino example using a MKR 1000 that has an incorrect schematic[^]*. And from there, I was down the rabbit-hole.
Okay, so now I was just trying to create a quick sound generator that I can use to input into the Analog 0 pin (A0) of my MKR Zero so I can test how the code works. I have a Grove Seeed Sound Sensor laying around so I find some sample code.
However, there is no explanation of this odd piece of code and I have to look at it closely.
Yes, it's a simple bitshift, but I had to think about what it does.
Do you see what it does?**
const int pinAdc = A0;
void setup()
{
Serial.begin(115200);
}
void loop()
{
long sum = 0;
for(int i=0; i<32; i++)
{
sum += analogRead(pinAdc);
}
sum >>= 5;
Serial.println(sum);
delay(10);
}
So it looks like it takes 32 samples each time through the loop and then it does that bit shift.
Interesting.
The code is from Grove - Sound Sensor[^]
*Bonus Material
The error in the schematic that is not in the breadboard example is that the schematic uses Amp2 OUT to go into the A0 pin on the Arduino even though there is no input on Amp2. The output should be from Amp1 to A0 on the schematic. See schematic at : https://www.arduino.cc/en/uploads/Tutorial/ArduinoMKR1000AudioInput_schem.png[^]
** spoiler Yep, it just clips off the 5 least significant bits, right? Well, it seems weird to do something like that without even mentioning why. This would've been a nice place in the code (or at the article) for a comment. But no.
modified 16-Oct-18 8:25am.
|
|
|
|