When management caught on that one of their lead developers was only good at talking about being a good programmer --- not at actually being one --- he was let go and Jimmy inherited the orphaned code-base. In order to cope, they've put up a bulletin board on which they post code that should never have been born. All of it is from the wake of this single developer.

Here's one of Jimmy's favorites. While he doesn't explicitly mention what language it is, I only know of one widely used language that goes out of its way to insult variables by calling them "dim." From the submission: "The idea is simple. Prompt the user for a file to import; pass this filename to a callback that will load and parse the file."

It's not surprising that the developer didn't know about System.IO.Path. What is surprising is the substitute, which doesn't use String.LastIndexOf or String.Substring.

  fileName = myDialog1.FileName
  Dim filePaths() As String = fileName.Split("\")
  Dim filePath As String
  Dim i As Integer
  For i = 0 to filePaths.Length - 2
      filePath.Append(FilePaths(i))
      filePath.Append("\")
  Next
  pathFile = filePath.ToString()
  fileName = filePaths(filePaths.Length - 1).toString()

 

Now, you may think that all of this is excusable. What if I told you that pathFile and fileName are each referenced only once in the rest of the code?

  Dim argumentString As New StringBuilder
  argumentString.Append(pathFile)
  argumentString.Append(fileName)