Can and Should with Legacy Constructs

Can and Should with Legacy Constructs

There are times where you wish you didn't have to worry about legacy code. This is particularly true with programming languages where constructs need to be supported even if they have long outlived their usefullness. Consider the following code that many of us "old-timers" learned to make the TRS-80 in the computer store go into an infinate loop (because the sales person didn't know how to break out of the loop).

Public Shared Sub Main()
     10:
Dim x As String = "This is a test" : Console.Write(x) : GoTo 10
End Sub

Ok, if you're paying attention, this isn't old VB code, but VB.Net (any version). Yes, you can still use line numbers, GoTo and the colon to put multiple statements in a single line. Repeat after me, "Just because you can doesn't mean you should."  Not only is this ugly code to maintain, but it's just sloppy. Please don't code like this.

Posted on 10/21/2008 2:09:00 PM - Comments(3)
Categories: VB Dev Center VB
Comments:
  • Gravatar Jim,



    I'll TRY to stop coding like that.



    --rj
    Roger Jennings (Posted on 10/21/2008 3:34:00 PM)
  • Gravatar This just reminds me of something I tell people all the time:

    A gun will let me shoot off my foot (and in some cases my mouth)... but that doesn't mean I should.



    I stopped using line numbers the day I discovered QBasic. I stopeed using GoTo shortly after that.




    Chris A (Posted on 10/28/2008 2:17:00 PM)
  • Gravatar Chris, I agree. I used to have a post regarding Extension methods being a big gun you could easily shoot yourself with. Unfortunately that post is gone when my old blog (devauthority) went under.
    Jim Wooley (Posted on 10/28/2008 2:25:00 PM)