
"I was really excited to write this article, because it gave me an excuse to really think about what beautiful code is. I still don't think I know, and maybe it's entirely subjective. I do think the two biggest things, for me at least, are stylistic indenting and maximum const-ness. A lot of the stylistic choices are definitely my personal preferences, and I'm sure other programmers will have different opinions. I think the choice of what style to use is up to whoever has to read and write the code, but I certainly think it's something worth thinking about. I would suggest everyone look at the Doom 3 source code
because I think it exemplifies beautiful code, as a complete package: from system design down to how to tab space the characters." John Carmack himself
replies in the comments.
Member since:
2006-05-30
Oh jesus.. no it's not! Here is an example:
Define a class and on that class create a public event
Public Class Whatever
...
Public Event MyEvent(ByVal SomeValue As String)
...
Public Sub RunHack(ByVal whatever as String)
MyEvent(whatever);
End Sub
End Class
Then in another class try this:
Public Class TwatFace
...
WithEvents myHack as Whatever
...
...
Public Sub ABadIdea(ByVal whatever as String) handles myHack.MyEvent
MsgBox(whatever)
End Sub
...
Public Sub LetsBreakEventHandling()
Dim fcukit As New Whatever
myHack = fcukit
myHack.RunHack("Shoot yourself now...")
End Sub
...
End Class
What happens if we call LetsBreakEventHandling? Well, it should never compile... it does. It should probably freak out and crash, but you'll see a message box happily telling you "Shoot yourself now...". And I know all of this because the fcukwit programmers, on contract from India, that we used before I took over didn't know about "AddHandler Xxxxx, AddressOf Yyyyy".
Even with option explicit and strict on, you can do this:
Dim X as Integer
X = 99
Dim Y as Boolean ''uninitialised, so compiler decides
Select Case X
Case 1, 2
Something()
Case 3, 4
Somethingelse()
Case Y
WhatThef--kDoesThisEvaluateTo()
End Select
VB is dangerous, plain and simple and there's nothing you can do in VB that can't be done in a safer .Net language at a similar speed.
Edited 2013-01-16 16:43 UTC