Can and Should with Legacy Constructs by ThinqLinq

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 - Comment
Categories: VB Dev Center - VB -
comments powered by Disqus