A small Horror
-
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 CompanyName
-
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 CompanyName
-
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 CompanyName
5nb_t wrote:
... this code was apparently auto-translated by a tool from C# to VB.NET...
Yes, but why??? :omg:
There are three kinds of people in the world - those who can count and those who can't...
-
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 CompanyName
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.
-
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.
At one of my early jobs there was a developer named Atul, I still laugh about it today. :-D
-
5nb_t wrote:
... this code was apparently auto-translated by a tool from C# to VB.NET...
Yes, but why??? :omg:
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.
-
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!
-
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++ :laugh:
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 :D
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!
-
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 :D
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!