|
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.
|
|
|
|
|
leppie wrote: This code was in fact generated... by a generator written by a tool.
|
|
|
|
|
How about a 13 month KPI that has code that has logic to work out the summary values to be displayed for each month, storing values used elsewhere in seperate variables (not an array) and then having that code duplicated 13 times (with a slight change in variables/controls). It would have been at least 10 pages and all embedded in the click event of the button .
After checking the code to see if anything else was buried in there I refactored this (with the help of a few functions) into two loops with about a dozen lines total. It helped because a bit later I found two other places where the same thing happened and while the code was different I was able to copy and paste the code and update the loop for the different KPI's.
|
|
|
|
|
Exactly what should have been done.
I see the same pattern as you described.
They use jQuery, so I dont understand why they can't even make it a one liner...
|
|
|
|
|
I was refactoring a horribly written app. Tons of duplicated code. Crazy amounts of dead code (~30-50%). And my personal favourite, was a method that went something like this.
public void Some_Method()
{
try
{
}
catch (Exception x)
{
LogException(x);
}
}
Fortunately, or not, this method was never called...but I sure am glad the catch block was there....just in case that empty try block failed.
|
|
|
|
|
I would call it a masterpiece.
|
|
|
|
|
The memorial of the never-written-code... with exception-handling
(yes|no|maybe)*
|
|
|
|
|
As a consultant I share your pain.
GibbleCH wrote: Tons of duplicated code. Crazy amounts of dead code (~30-50%)
sounds like it would be quicker to re-write
|
|
|
|
|
Ultimately that was the result. But using lots of unit tests and refactoring to do so. Less error prone, and I was able to ensure functionality remained consistent where it was correct. And some bits of the app did work...
|
|
|
|
|
I see the opposite way to often too...
Private Sub DoSomething
Try
Catch ex As Exception
End Try
A Try Catch block with no code does no harm, this however...
Perhaps the empty Catch is also VB6 inspired... OnErrorResumeNext
It's an OO world.
|
|
|
|
|
Naerling wrote: Perhaps the empty Catch is also VB6 inspired... OnErrorResumeNext
Is it just me or everytime someone talks about bad code, "VB" shows up?
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
|
|
|
|
|
I blame VB 1, 2 and 3.
I was a toddler at that time so I wouldn't know, but this is what I heard.
VB became object oriented at version 4, but to be backwards compatible MS had to support the non-object oriented style.
As a result many VB programmers kept on programming like they always did and still do so today.
Why not C#? Because the first C# came at around the same time as VB4 and was object oriented right from the start.
On a side note, try to call any PUBLIC member of a Form in VB without having an instance of the Form. It will work, you can call them as if they were Shared (static). I recently found out and was shocked, backwards compatibility with VB1...
Anyway, I don't really blame VB, I blame the programmers who were not willing to learn object orientism right after VB3
Does that sound about right or am I really way off here?
It's an OO world.
|
|
|
|
|
Naerling wrote: VB became object oriented at version 4
Not fully, still lacked lots of OO principles, even VB 6 (like something as basic as inheritance).
Naerling wrote: I blame the programmers who were not willing to learn object orientism right
after VB3
I actually seen that in action on VB.Net.
Naerling wrote: Does that sound about right or am I really way off here?
Yes, it does. But in my opinion that's not the full story and the full story about all the VB infame does not apply to everyone and to all scenarios. But yes, the word VB gives me goose bumps, specially when I learn I have to work with existing code.
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
|
|
|
|