| « Getting Past Security | The Hard Way » |
Originally posted by "Publius"...
I'm working on VB6 code written by a Dutch speaker and maintained by an Italian, with variables and comments in both languages. And no indentation whatsoever.
Rather than use a string array, the original developers repeatedly feed the same, massive string literal into the Split function. This is done for every string resource the program uses.
For reasons beyond my understanding, there is this:
ikownjou = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...[snip]" & Chr(1) ikownjou = ikownjou & "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...[snip]" & Chr(1)Also, there are 40 timers on the main form, all arranged in a grid. It looks like Flava Flav's coat of arms.
Rather than use different resource files for the eight languages it's translated to, all four billion or so captions and menu items are set with a separate call to the locale("resource_name") function whenever a form is loaded. And whenever the locale() function is called, it opens a file, looks for the entry for the current language, and then closes the file.
Rather than use "Sub", they always use a "Function" with no return value that's peppered with about 70 "Exit Function" statements throughout its body.
Rather than use a database, all non-static information is crammed in thousands of text files scattered across subfolders of subfolders. Their version of "SELECT * FROM" is "DIR *.txt".
I replaced 4002 lines of this:
Public Function B64Length(ByVal TheString As String) As Integer Select Case TheString Case "@@" B64Length = 0 Exit Function Case "@A" B64Length = 1 Exit Function Case "@B" B64Length = 2 Exit Function Case "@C" B64Length = 3 Exit Function Case "@D" B64Length = 4 Exit Function ----------[snip]------------ End Select End FunctionWith two lines:
Private Const B64Compare = _
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}- €" Public Function B64Length(ByVal strEncoded As String) As Integer B64Length = (InStr(1, B64Compare, Left(strEncoded, 1)) - 1) _
* 64 + (InStr(1, B64Compare, Right(strEncoded, 1)) - 1) End Function
|
And for those interested... 'IkOwnJou' translates to 'I Own You', without spaces ofcourse.
Yeah, i wonder if he's still as full of himself when he reads this article... |
|
"Rather than use a database, all non-static information is crammed in thousands of text files scattered across subfolders of subfolders"
Accessing the file system directly is clearly faster than creating a DB connection and THEN looking for your data. A database is nothing more than a glorified set of files! |
|
Oh jeez, I didn't know this would make front page, I would have edited to add a couple things I've discovered since then.
The reason there are 70 "Exit Function" statements: they use it instead of "ElseIf" and "Else" (despite knowing how to use these elsewhere in the code). If True Then DoThis Exit Function End If If False Then DoThat Exit Function End If If ... [snip] To pass information between forms, the concept of scope eludes them. They make a hidden TextBox and stuff information in it for other forms to read. |
| « Getting Past Security | The Hard Way » |