|
That won't work on a German system: boolVar.ToString evaluates to "Wahr" or "Falsch". Some time ago I posted a coding horror where just that happened by implicit conversion from bool to string.
|
|
|
|
|
|
I hope this code didn't get in to production because it doesn't work. Try
TruthChecker(false, 1)
I think this will return true
|
|
|
|
|
I feel that it makes reading a program easier when actually seeing the True as well as it's less error prone:
MY ARGUMENT TO MY 2 POINTS:
1) VISIBLE
Using the statement:
If (myControl.Visible = True) Then
I immediatly know that Visible is a boolean.
2) LESS ERROR PRONE
What happens if Visible is actually an unsigned int which can range from 0 to 10 but the programmer forgot to program it correctly?
E.g.
HE WROTE:
If (myControl.Visible)
INSTEAD OF:
If (myControl.Visible < 10)
This type of bug would be difficult to find if you write your boolean if statements without the True, however easy if not.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
I've seen similar stuff many, many, many times. I believe the author is paid not only for lines of code but for columns as well.
|
|
|
|
|
I hate to say it, but I do that boolean crap in if...thens. It's the only way some people can understand the code when they read it.
|
|
|
|
|
Just found this piece of quality in our production code.
try
{
Class1.NullableInt1 = int.Parse(txtSomeUserInput.Text);
}
catch
{
Class1.NullableInt1 = null;
}
...
NB: Class, property and input names changed to protect the inocent.
And people here wonder why our web forms can take 1 minute or more to post back!
|
|
|
|
|
Sadly, the sucker never heard of the Convert class...
|
|
|
|
|
|
Seeing far too much code like that is what made me choose my signature line.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
if (FileType = 0) then
FileSaveAs(Sender)
else begin
case FileType of
1:SaveCDL(FileName,List);
2:SaveDXF(FileName,List);
3:SaveFile(FileName,List);
end;
end;
I came across this in some code (written by someone else) that I am looking through to find the cause of a save/load error.
The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill
America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde
Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin
|
|
|
|
|
|
Is it about
FileType=0 being an assignment instead of comparison?
Greetings - Jacek
|
|
|
|
|
no, this is the VB way of comparison
|
|
|
|
|
It seems to be Pascal, not VB. But, in Pascal = is also a comparison, AFAIR. Frankly, I don't see where the horror is.
Greetings - Jacek
|
|
|
|
|
omg yes it's PASCAL ... guess the horror is the fact, that there is no need for the outer IF, because it could be handled inside the CASE as well
|
|
|
|
|
TorstenFrings wrote: no need for the outer IF, because it could be handled inside the CASE
Yeah, that's it. Having the if instead of just case 0 seems a bit like someone wasn't actually thinking about what they were coding.
The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill
America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde
Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin
|
|
|
|
|
Jacek Gajek wrote: It seems to be Pascal, not VB.
It's Delphi. So, you were almost right.
The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill
America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde
Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin
|
|
|
|
|
Colin Mullikin wrote: It's Delphi. So, you were almost right.
He was absolutely right. Delphi is not a programming language, it's IDE just like Visual Studio. Object Pascal is used as a programming language inside. I know what I'm talking about. I had the pleasure of working with Delphi/C++ Builder. It was more than 5 years ago though. I still remember C++ Builder 6. But Borland is dead now .
|
|
|
|
|
Oh, sh*t, Pascal Haven't seen it for several years. Is Delphi still alive? Anyway wouldn't it be easier to write something like
case FileType of
0:FileSaveAs(Sender);
1:SaveCDL(FileName,List);
2:SaveDXF(FileName,List);
3:SaveFile(FileName,List);
end;
Or religion doesn't allow? Sorry for possible syntax mistakes. But like I said: I haven't seen it for several years.
modified 6-Aug-12 16:22pm.
|
|
|
|
|
Yep, you hit the nail on the head with that one. I have no clue why the original programmer didn't do that in the first place. I changed it to that, since it looks much cleaner.
The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill
America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde
Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin
|
|
|
|
|
WTF~!!!!!!!!!!!
var key = "13870";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13886";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13905";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13910";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13918";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13922";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13927";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13930";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13948";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13965";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "13986";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
var key = "14002";
var checkboxName = key + "_Selected";
var commentName = key + "_Comments";
if(document.getElementById(checkboxName).checked == true)
{
document.getElementById(commentName).value = commentBox.value;
appliedToCount ++;
}
Update:
This code was in fact generated... Refactoring, thy name is frailty!
|
|
|
|
|
leppie wrote: .checked == true
This is an instance of shame within a shame.
|
|
|
|
|
I presume each of these duplicated sections was in it's own method, otherwise it won't even compile. Since each var statement keeps declaring variables that are already declared.
|
|
|
|
|
It is acceptable javascript.
|
|
|
|