|
I got a headache after the word Sub in line 1 and stopped reading.
Vita est usquequaque virtus victus ut plenus. Ego non sum semper iustus tamen Ego sum nunquam nefas!
|
|
|
|
|
Did the author die?
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
That depends. Did the person who maintained the code have his home address?
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I have seen worse Russian code.
Best thing to do with monster code is to use some reflections on it.
|
|
|
|
|
Most code is like Dr.Frankenstein's mosnter. The only difference between good monster and bad monster is the good one has it's legs and hands and all else where they should be.
|
|
|
|
|
This is some sample code from an SDK, published by a medium-sized company who I will of course not name. (For one thing, my job is somewhat tied to their work... .)
It was so bad I rewrote it in place, and I couldn't resist a side-by-side comparison of my code and the original code.
(Side note: this code was apparently auto-translated by a tool from C# to VB.NET at some point during its life... it's possible that some of the horror is auto-generated, but how much of this could be from that source? And anyway, that's pretty bad in itself.)
''' <summary>
''' Parses the Input txt File by Rows and returns a array of string of input rows
''' </summary>
''' <param name="filelocation">System Path of the File </param>
''' <returns></returns>
Private Function ParseTheFileByLine(ByVal filelocation As String) As String()
' This is my code; the XMLdoc comments and method signature are unchanged,
' except that I fixed capitalization.
Try
Using sr As New StreamReader(filelocation)
Dim ares As New List(Of String)
Do Until sr.EndOfStream
ares.Add(sr.ReadLine())
Loop
Return ares.ToArray()
End Using
Catch ex As IOException
Dim hh As New System.Collections.ArrayList(1)
hh.Add("Invalid Input File " & ex.Message)
' CompanyNameBrandedCustomValidationException is not, of course, the real
' name of the exception in question because, as the name implies, it
' contains the company's real name.
' And yes, its constructor does require an ArrayList. No, I don't quite
' know why. Chalk another one up to general incompetence or just garden-
' variety peculiarity.
Throw New CompanyNameBrandedCustomValidationException(hh)
End Try
' Here is the original miserable code, commented out (the way I left it
' there for possible "future use"...).
' Dim fs As FileStream = Nothing
' Dim fs1 As FileStream = Nothing
' Dim sr As StreamReader = Nothing
' Dim sr1 As StreamReader = Nothing
' Try
' fs = File.OpenRead(filelocation)
' fs1 = File.OpenRead(filelocation)
' sr = New StreamReader(fs)
' sr1 = New StreamReader(fs1)
' Catch Ex As Exception
' Dim hh As New System.Collections.ArrayList(1)
' hh.Add("Invalid Input File " & Ex.Message)
' Throw New CompanyNameBrandedCustomValidationException(hh)
' End Try
' Dim input_Array_Lines() As String = Nothing
' Dim input_line As String = ""
' Dim num_of_Lines As Integer = 0
' Try
' Do While sr1.Peek() > -1
' input_line = sr1.ReadLine()
' num_of_Lines += 1
' Loop
' Catch a As Exception
' Dim hh As New System.Collections.ArrayList()
' hh.Add("Invalid Input File " & a.Message)
' Throw New CompanyNameBrandedCustomValidationException(hh)
' End Try
' If num_of_Lines > 0 Then
' input_Array_Lines = New String(num_of_Lines - 1) {}
' End If
' num_of_Lines = 0
' Try
' Do While sr.Peek() > -1
' input_line = sr.ReadLine()
' input_Array_Lines(num_of_Lines) = input_line
' num_of_Lines += 1
' Loop
' Return input_Array_Lines
' Catch a As Exception
' Dim hh As New System.Collections.ArrayList()
' hh.Add("Invalid Input File " & a.Message)
' Throw New CompanyNameBrandedCustomValidationException(hh)
' End Try
End Function
I realize this code is not quite down to the ordinary standards of the Coding Horror, but still, it's pretty bad.
The worst? It's a helper function in a form file with over 10000 lines of code. Complete kludge all the way through. Tune in next time for more cleaned-up code samples....
|
|
|
|
|
yes anythign VB is a horror
|
|
|
|
|
That's such a shallow argument. And actually quite racist when you think about it.
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
VB is not a race is is a mere spec of old chewing gum on the golden walk way of C/C++
|
|
|
|
|
If you mean VB and not VB.Net, I so agree. The TS wrote VB.Net though.
Btw, this is not only racism, this is even pure discrimination!!! A programming language has rights you know!!!
Go hang this[^] above ur bed or sumetin
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
omgz my new backround and screen saver image
|
|
|
|
|
5nb_t wrote: ... this code was apparently auto-translated by a tool from C# to VB.NET...
Yes, but why???
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Ah, now that would be telling... I think it's because I work in a (small) VB-only shop, and although I know C# well enough I didn't need the translation, I don't think the other devs do.
A micro-horror, I guess.
|
|
|
|
|
5nb_t wrote: this code was apparently auto-translated by a tool
Which one was the tool, the author of this horror or the utility?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
At one of my early jobs there was a developer named Atul, I still laugh about it today.
|
|
|
|
|
Hi,
Trying to create a create an application using C#.
Having two a list box, which is display the files from the windows folder say "Pick".
This folder is implemented with folder watcher. As soon as any file is coming into this folder, that file is processing is some way.
The functionality as .. as soon as any file come into this folder "Pick".
My list box should , display this new entered file.
Is this possible using Winforms.
Thanks,
|
|
|
|
|
Try to post this in the C# forum, this is the wrong place!
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
I think what he means is that whatever he writes will be a horror!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
That would be the first person that admit first and then code.
I thought of pointing out something like that, but since the sun is shining and I am in a good mood.
I didn't wan't to be cruel.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
From our own C# forum again:
Hi!
In a simple game I'm creating, I need to trigger some methods when one of the arrow keys are
pressed as well as the space key.
I'm using this code in the form to receive the keyboard inputs:
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.KeyCode == Keys.Up && e.KeyCode == Keys.Space)
MessageBox.Show("UP & SPACE");
}
Nothing happens when I run the code. The OnKeyDown event don't seem to handle this condition at all.
How shall I solve this problem?
Um - what do they teach them? And why?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
|
The answer's in the code. UP in SPACE is where the coder seems to be.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
|
No, this was originaly posted in the C# forum by Mc_Topaz and I copied it here as an example of "why the hell did you do that and then ask why it doesn't work?". Hence the "From our own C# forum" and "What do they teach them" bits.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Andrew Pallant wrote: I am not one to usually say anything about posting in the wrong forum, but you really did this time.
Did you actually read the post? The OP didn't post a programming question at all, he's pointing out a very misguided bit of code posted by someone else.
|
|
|
|