Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. A small Horror

A small Horror

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpquestiondata-structureslounge
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nathan Tuggy
    wrote on last edited by
    #1

    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
    
    K M P 3 Replies Last reply
    0
    • N Nathan Tuggy

      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
      
      K Offline
      K Offline
      killabyte
      wrote on last edited by
      #2

      yes anythign VB is a horror

      J 1 Reply Last reply
      0
      • N Nathan Tuggy

        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
        
        M Offline
        M Offline
        molesworth
        wrote on last edited by
        #3

        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...

        N 1 Reply Last reply
        0
        • N Nathan Tuggy

          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
          
          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          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

          P 1 Reply Last reply
          0
          • P Pete OHanlon

            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

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            At one of my early jobs there was a developer named Atul, I still laugh about it today. :-D

            1 Reply Last reply
            0
            • M molesworth

              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...

              N Offline
              N Offline
              Nathan Tuggy
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • K killabyte

                yes anythign VB is a horror

                J Offline
                J Offline
                Jeroen De Dauw
                wrote on last edited by
                #7

                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!

                K 1 Reply Last reply
                0
                • J Jeroen De Dauw

                  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!

                  K Offline
                  K Offline
                  killabyte
                  wrote on last edited by
                  #8

                  VB is not a race is is a mere spec of old chewing gum on the golden walk way of C/C++ :laugh:

                  J 1 Reply Last reply
                  0
                  • K killabyte

                    VB is not a race is is a mere spec of old chewing gum on the golden walk way of C/C++ :laugh:

                    J Offline
                    J Offline
                    Jeroen De Dauw
                    wrote on last edited by
                    #9

                    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!

                    K 1 Reply Last reply
                    0
                    • J Jeroen De Dauw

                      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!

                      K Offline
                      K Offline
                      killabyte
                      wrote on last edited by
                      #10

                      omgz my new backround and screen saver image ;P

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups