A whole database of WTF



  • As a side task at work i took it upon myself to document a god-awful database, so that once we understood what it actually did, we could write something better. I'm confronted almost immediately with pages of crud like this:

     

    Dim WD1 As Integer
    WD1 = (DatePart("ww", Date))
    If WD1 > 14 Then
    WD1 = WD1 - 14
    ElseIf WD1 <= 14 Then
    WD1 = WD1 + 38
    End If
    If WD1 = 1 Then
    MsgBox "It is the Start of a new year. Do you want to archive last years Transactions now?"
    End If

     

    (yes this is access 97... a WTF in itself these days) - note that the msgbox call doesnt actually TRIGGER anything, it just asks, and does nothing.



  • Does it do anything else with WD1 after this? I'm somewhat bothered by
    the fact that there can be more than 52 weeks in the year.



  • ISO week numbering (used for tax purposes in a few countries) declares that Week 1 is the week containing the year's first thursday or January 4. Which means that in some years the first few days are still considered Week 52 of the previous year, or that some years have indeed 53 weeks.



  • Yes, I know, having implemented strftime a couple of times and thus
    dealt with three different week numbering schemes. The above
    manipulations of WD1 can only produce week numbers between 1 and 52
    inclusive.



  • Teach me to not read the code properly. I misunderstood what you meant
    when you said there can be more than 52 weeks. You meant, 'it's
    possible', I understood 'how can there'...



    It's late...



  • @braindigitalis said:

    note that the msgbox call doesnt actually TRIGGER anything, it just asks, and does nothing.




    There was a dialogue box in SimCity 2000 that said:



    "Are you sure you want to remove this bridge?"

    [OK]



    The Map24 java app, upon connection timeout, asks:



    "Reconnect to server?"

    [OK]



  • This WTF is also a nice violation of the Magic Number principle. Or should I say 'adherence'?



  • @Ben Hutchings said:

    Does it do anything else with WD1 after this? I'm somewhat bothered by the fact that there can be more than 52 weeks in the year.

    Yes. It then takes the week number and uses it to calculate how much a worker should be paid for the week (i dont know why the week number is used here).

    It takes the number of hours worked (as a real number) and checks if its > 0.75. if it is, it makes it 1. Otherwise, if its greater than 0.5, it makes it 0.75. If its greater than 0.25, it makes it 0.5 and if its greater than 0 but less than the rest it makes it 0.25. I'm assuming this is to round off their working time to the nearest quarter of an hour, but then what it does boggles the mind -- it adds a RANDOM number between 1.25 and 1.75 to the result... now that is just odd, whoever heard of PAYMENT systems utilizing random numbers? Yes, ive heard of uses like this to account for errors in rounding, but only on ancient systems that had very very bad floating point support -- not access...anyone else seen this before?



  • Sounds to me like it's a case of "Ah, well, on average everyone will get the right amount". Have none of the workers ever complained about their pay being different every month (week)?



  • no they havent. Come to think of it i havent found a randomize function, i don't remember if VBA has such a function but it would explain why there are no complaints if the random number isnt even seeded!

     

    It will probably be my job to rewrite this properly ...that is if we can ever figure out what it does and why.



  • Randomizing in VBA is easy

    use Randomize (seed) to seed the random number - I usually use 'timer' (a function that returns the number of seconds since midnight) for a seed.

    The function Rnd() will return the actual random number.



  • @braindigitalis said:

    but then what it does boggles the mind -- it adds a RANDOM number between 1.25 and 1.75 to the result... now that is just odd, whoever heard of PAYMENT systems utilizing random numbers?

    <FONT face="Courier New" size=2>ah, i've got it.  this was modified from the code that added the paid lunch hour in it.  if you randomly add between 15-45 minutes to your day, you can also account for bathroom breaks and the like.  or, alternatively, somebody really wanted to leave a little early and beat traffic.</FONT>



  • @emptyset said:

    @braindigitalis said:

    but then what it
    does boggles the mind -- it adds a RANDOM number between 1.25 and 1.75
    to the result... now that is just odd, whoever heard of PAYMENT systems
    utilizing random numbers?

    <font face="Courier New" size="2">ah, i've got it.  this was modified from the code that added the paid lunch hour in it.  if you randomly add between 15-45 minutes to your day, you can also account for bathroom breaks and the like.  or, alternatively, somebody really wanted to leave a little early and beat traffic.</font>



    that was the programmer of this DB no? the one that wanted to beat traffic?
    would explain the strange random addition - no workers will complain, they get a slightly increased pay, and the accounts dont notice, because hey - its a computer, and since when do u need to check the output of a computer??....

Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.