|
I had to stare at that for a good 30 seconds before I spotted the bug. Gosh - I need a decent compiler at this time in the morning to help me!
|
|
|
|
|
|
Ok, it took me a while to see the ";" after the first "if". You would have done me a great favor by simply mentioning that in your message. It's funny!
I just wanted to say that I know what you mean. I'm stuck with something similar. Lots of code doing nothing. I can't believe you actually took the time to count the lines of code! All I can say is that the program I have to work on has about 30000 files of source organized in about 2000 folders.
So, if there were about 400 lines of code per file, that would make a total of 12 million lines of code! However, that's an understatement, since most files have more than 400 lines of code.
When I run into errors like this I think a lot about whether I should fix them or not, since doing so might actually be causing a bug. ) I took up assembly language a long time ago, just because of this. C++ and all other high level programming languages are supposed to be related a great deal to human language. But people say stupid things all the time.
|
|
|
|
|
|
Real nasty ones these; you just read straight over the problem and not notice it 9 times out of 10.
Steve
|
|
|
|
|
This is a good candidate for the Subtle bugs forum.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Not if they determined "it's not a bug".
|
|
|
|
|
And believe what? For them, it wasn't a bug, since it always worked "well" before! At first, they tought it was a typing mistake made accidentaly by me until they looked into SourceSafe and agreed that the mistake was there too, since a couple of years before!
Progamming looks like taking drugs...
I think I did an overdose.
|
|
|
|
|
Yeah, definitively!
Progamming looks like taking drugs...
I think I did an overdose.
|
|
|
|
|
I overdosed a long time ago…
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I'm in detoxification right now. Should be able to get hooked again in a few months...
Progamming looks like taking drugs...
I think I did an overdose.
|
|
|
|
|
well, it did not take me even a minute to spot that. i caught the error as soon as i read that there was an error in the code.
Regards,
Vijay.
God may not give us what we 'want', but he surely gives us what we 'need'.
|
|
|
|
|
who else sees this and just laughs:
if (whatever == true){
chkBox.Checked = true;
}else{
chkBox.Checked = false;
}
|
|
|
|
|
In opposition to my own statement below I would probably do the following in this case.
CallUpdateFunction(chBox.Checked)
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
if (whatever == true) {
chkBox.Checked = true;
} else {
chkBox.Checked = false;
} else {
...
}
/ravi
|
|
|
|
|
This was discussed in an earlier thread.
Kevin
|
|
|
|
|
Well, this takes that a step farther; not just the test, but the setting of another boolean.
Every once in a while I catch myself doing that and I have to slap my hand.
|
|
|
|
|
Its junk.
chkBox.Checked = whatever;
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
Captain See Sharp wrote: chkBox.Checked = whatever;
yeap you right.. you giving variable some unknown garbage value by doing so!
|
|
|
|
|
i agree - i would aslo have used this
|
|
|
|
|
I see it all the time.
have also found this before
chkBox.Checked = !(whatever == true);
I think(hope) that these are normally incremental errors where the code has been tweaked bit by bit over the course of years. Boolean logic always seems to have people a bit stumped though and i'm never sure why.
I've seen a few things like these in the past
if (whatever || true) doStuff();
if (whatever && false) doStuff();
Russ
|
|
|
|
|
I'll admit to occasionally ending up with something like this after hacking out part of a complex conditional or breaking it into several smaller lines, and not doing a sanity check with the remaining chunks.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
I do that all the time when I debug and test extreme cases which are hard to simulate using input. I wouldn't want to be caught forgetting about them though.
--
For proper viewing, take red pill now
|
|
|
|
|
This is bad practice unless the language automatically converts between variable types. If that is the case then you could essentially assign any value to the object if you aren't careful.
Brad
Australian
- Bradml on "MVP Status"
If this was posted in a programming board please rate my answer
|
|
|
|
|
innominate wrote: and just laughs:
No, I cringe
|
|
|
|