The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Possibly the worst codebase ever.

Last post 01-29-2008 9:56 AM by DaveK. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 01-28-2008 5:46 PM

    Possibly the worst codebase ever.

    I'm working on VB6 code written by a Dutch speaker and maintained by an Italian (with variables and comments in those languages), with no indentation whatsoever.

    Rather than use a string array, they repeatedly feed the same massive string literal into a Split function. This is done for every string resource the program uses.

    For reasons beyond my understanding, there is this:
    ikownjou = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...[snip]" & Chr(1)
    ikownjou = ikownjou & "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...[snip]" & Chr(1)

    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 8 languages it's translated into, every time a form is loaded all 4 billion captions and menu items are set with a separate call to the 'locale("resource_name")' function which opens a file, looks for the entry for the current language, and 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.

    All the non-static information is crammed in thousands of text files scattered across subfolders of subfolders, rather than in a database. 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 Function

    with 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

  • 01-28-2008 5:56 PM In reply to

    Re: Possibly the worst codebase ever.

     What sort of application needs 40 timers on a form?

     I haven't used VB since VB5...but that boggles my mind.

  • 01-28-2008 6:05 PM In reply to

    Re: Possibly the worst codebase ever.

    btw, 'ikownjou' means  'I own You' or 'I PWN YOU'

  • 01-28-2008 6:07 PM In reply to

    Re: Possibly the worst codebase ever.

     

    Jonathan Holland:

     What sort of application needs 40 timers on a form?

     I haven't used VB since VB5...but that boggles my mind.

    The worst possible kind?

    Behold! SpectateSwamp: The Stupidest Man on Earth

    No, my apache isn't running linux :( My ubuntu box is at home. -- malfist

    Brilliant!

    Join our IRC channel #TDWTFMafia on irc.slashnet.org! All are welcome.
  • 01-28-2008 11:39 PM In reply to

    • PJH
    • Top 25 Contributor
    • Joined on 02-14-2007
    • Posts 596

    Re: Possibly the worst codebase ever.

    Publius:
    There are 40 timers on the main form, all arranged in a grid. It looks like Flava Flav's coat of arms.
    Not having heard of Falva Flav, and thus unable to visualise his coat of arms, I went in search:

    http://images.google.co.uk/images?svnum=100&um=1&hl=en&q=Flava+Flav+coat+of+arms&btnG=Search+Images

     None of these looks like a VB form I've ever seen. Should I be looking under ssds://flava+flav+coat+of+arms ?

    This is not a problem that requires infinite wisdom, Benj. This is a problem that requires enough neural organization to qualify as a vertebrate, apparently a stretch for some folks these days.
    - Cecil Adams.
  • 01-29-2008 2:27 AM In reply to

    • insta
    • Not Ranked
    • Joined on 11-29-2006
    • Posts 14

    Re: Possibly the worst codebase ever.

    Without bashing the language,

    VB6 cannot spawn a popup menu from a spawned form, if the spawned form was done in the event handler of a popup menu in the main form.  So, if you have main form A, and subform B ... if you right click on A and click the option that spawns B, B can't have a popup menu on it.  The way to do it is to create a timer on A, with an interval of 1ms, and spawn form B.  The timer disables itself in the event, and the timer is enabled by clicking the menu option.  That way VB can dispose of its menu properly without breaking sub forms.

  • 01-29-2008 4:49 AM In reply to

    Re: Possibly the worst codebase ever.

    PJH:

    Publius:
    There are 40 timers on the main form, all arranged in a grid. It looks like Flava Flav's coat of arms.
    Not having heard of Falva Flav, and thus unable to visualise his coat of arms, I went in search:

    http://images.google.co.uk/images?svnum=100&um=1&hl=en&q=Flava+Flav+coat+of+arms&btnG=Search+Images

     None of these looks like a VB form I've ever seen. Should I be looking under ssds://flava+flav+coat+of+arms ?

    Wikipedia:
    Flavor Flav's visual trademark is an oversized clock hanging from his neck.

     http://images.google.co.uk/images?q=Flava+Flav

     


     


    TRWTF is Community Server
  • 01-29-2008 5:02 AM In reply to

    • DOA
    • Top 100 Contributor
    • Joined on 06-26-2007
    • Posts 279

    Re: Possibly the worst codebase ever.

     I admire your courage. If I had to maintain that, sooner or later I would end up on the evening news.

    And after that there would be new legislation on gun control. 

  • 01-29-2008 9:56 AM In reply to

    Re: Possibly the worst codebase ever.

    insta:
    Without bashing the language,

    I think you demonstrated that even just to explain it is inherently to bash it.

Page 1 of 1 (9 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems