• SR (unregistered)

    zzFirst

  • (cs) in reply to SR

    I have nothing funny to say. I just want to bitch-slap the alleged "programmers" who do this, because I've seen it far far too often.

  • zzFirst1 (unregistered)
  • (cs)

    zzzzz*! Huh? Wha? Did he at least pick one of the duplicated functions and implement the others in terms of that one? At least that way, you can eventually stream edit the code to remove all the duplicity.

  • (cs)

    Still can't concentrate on work. Currently imagining Charlize Theron and Nicole Kidman making out. Dammit.

    Skizz

    P.S. Those coders should be rounded up in a field and nuked from a great height, just to be sure.

  • (cs)

    Global search and replace is your friend.

  • (cs)

    The biggest WTF is the file name. Surely it should be zzGeneralFunctionsPluralZAlpha.

    Skizz

  • Anon (unregistered)

    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.

  • Single User (unregistered) in reply to Anon
    Anon:
    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.
    It's for concurrency. If MonthName is already running in another thread, you can fall back on using GetMonthName. Clear as daylight.
  • monkeyPushButton (unregistered) in reply to Anon
    Anon:
    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.
    Well, they probably already had it in their code and this was faster than changing the call in their code. Besides, just this one time...
  • Razumny (unregistered)

    Sing it with me:

    I love code'n'roll/so come on do recursion with me I love code'n'roll/so put another snippet in the GeneralFunctions yeah!

  • (cs) in reply to Anon
    Anon:
    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.
    I suspect that they copy-pasted it from some crappy website, and then someone else did exactly the same thing.
  • nonny nonny (unregistered)

    Rats, I need to get the month name, but all in upper case. Guess I'm writing another function from scratch.

  • Cas (unregistered)

    The comments at the top should have read:

    'Any time you want to do something, check if it already exists in a function here; if so, use that function to do that thing. 'If you do something more than once and it doesn't already exist in a function here, add a function here to do it and replace your existing code with calls to that function. 'If you're feeling crazy, add details of what your function does in a comment at the top. But don't strain yourself.

  • ThatGuy (unregistered)

    What would make this even better is if this was for the National Institute of Health (NIH).

  • dave (unregistered)

    First!!2

    nothing like repeating what someone's already said

  • (cs)

    zzGetFirst

  • BoBThESeXy (unregistered)

    It's like trying to recreate wheel. Except the wheel is lumpy, deformed, and irritatingly stupid.

  • (cs) in reply to Cas
    Cas:
    The comments at the top should have read:

    'Any time you want to do something, check if it already exists in a function here; if so, use that function to do that thing. 'If you do something more than once and it doesn't already exist in a function here, add a function here to do it and replace your existing code with calls to that function. 'If you're feeling crazy, add details of what your function does in a comment at the top. But don't strain yourself.

    'Before writing a stupid function, see if it's already implemented by any of our API or libraries, it's probably better than yours'

    There, now is complete

  • (cs) in reply to BoBThESeXy
    BoBThESeXy:
    It's like trying to recreate wheel. Except the wheel is lumpy, deformed, and irritatingly stupid.
    And also made of jell-o.
  • AnyonymousOrSmthing (unregistered)

    I'll add this:

    'Before writing a new function be really , and I mean really, sure that said function is not stupid, kkthxbye'

  • Charlie Very Sure (unregistered)
    By the time Mark got to zzFormatDate4, he just gave up looking. It was going to be a very long maintenance project.
    Yeah, I mean, imagine if you had to add another month to every one of those functions! Kinda like Y2K: miss one and the world falls apart.
  • (cs) in reply to Charlie Very Sure
    Charlie Very Sure:
    By the time Mark got to zzFormatDate4, he just gave up looking. It was going to be a very long maintenance project.
    Yeah, I mean, imagine if you had to add another month to every one of those functions! Kinda like Y2K: miss one and the world falls apart.
    You mean, like for folks that use lunar calendars? Cuz that never happens.
  • Marc B (unregistered) in reply to Single User
    Single User:
    Anon:
    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.
    It's for concurrency. If MonthName is already running in another thread, you can fall back on using GetMonthName. Clear as daylight.

    Yeah, but I'm planning on running 10 simultaneous threads, and I'm running out of names:

    Thread 1: MonthName Thread 2: GetMonthName Thread 3: TheMonthName Thread 4: GetTheMonthName Thread 5: MonthsName Thread 6: GetMonthsName Thread 7: TheMonthsName Thread 8: GetTheMonthsName

    What do I do for 9 and 10?!?

  • pseudocode (unregistered)

    I tell you why they wrote these. Try and use the VB builtins! They depend on system settings such as the current language of the logged-on user. At least these hardcoded functions produce predictable results!

  • AnotherAnonymous (unregistered)

    #1: Maybe the coder fell asleep while coding it?

    #2: Don't be ridiculous. If he had fallen asleep, he wouldn't have typed out "zz", he would have just snored.

    #1: Perhaps he was dictating.

  • Anon (unregistered) in reply to Marc B
    Marc B:
    Single User:
    Anon:
    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.
    It's for concurrency. If MonthName is already running in another thread, you can fall back on using GetMonthName. Clear as daylight.

    Yeah, but I'm planning on running 10 simultaneous threads, and I'm running out of names:

    Thread 1: MonthName Thread 2: GetMonthName Thread 3: TheMonthName Thread 4: GetTheMonthName Thread 5: MonthsName Thread 6: GetMonthsName Thread 7: TheMonthsName Thread 8: GetTheMonthsName

    What do I do for 9 and 10?!?

    Thread 9: GetNameOfMonth Thread 10: GetNameOfTheMonth Thread 11: NameOfTheMonth Thread 12: NameOfMonth Thread 13: ...?

  • iToad (unregistered)

    Maybe there is a company requirement that all new programmers must write their own version of a month name format function, and add it to the file.

  • (cs) in reply to ThatGuy
    ThatGuy:
    What would make this even better is if this was for the National Institute of Health (NIH).

    Why?

  • (cs) in reply to ThePants999
    ThePants999:
    Anon:
    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.
    I suspect that they copy-pasted it from some crappy website, and then someone else did exactly the same thing.
    TheDailyWTF better start securing it's code a little better then *wink*
  • ih8u (unregistered) in reply to Marc B
    Marc B:
    Single User:
    Anon:
    I love that MonthName and GetMonthName are identical, even down to the commented out line, which suggests that somebody saw the first function that did exactly what they wanted and decided to copy/paste the function and give it a new name. Clearly they don't understand the purpose of functions.
    It's for concurrency. If MonthName is already running in another thread, you can fall back on using GetMonthName. Clear as daylight.

    Yeah, but I'm planning on running 10 simultaneous threads, and I'm running out of names:

    Thread 1: MonthName Thread 2: GetMonthName Thread 3: TheMonthName Thread 4: GetTheMonthName Thread 5: MonthsName Thread 6: GetMonthsName Thread 7: TheMonthsName Thread 8: GetTheMonthsName

    What do I do for 9 and 10?!?

    Generally, you would start with blatant mispellings: GetTehMonthName, GetTheMothName, etc.

    Then you could try using different languages by translating the method name to French, German, Spanish, etc. Just use babelfish.

    Also you could use another name entirely: strcmp, format, JessicaSimpson, etc.

    HTH

  • (cs) in reply to Anon
    Anon:
    Marc B:
    Yeah, but I'm planning on running 10 simultaneous threads, and I'm running out of names:

    Thread 1: MonthName Thread 2: GetMonthName Thread 3: TheMonthName Thread 4: GetTheMonthName Thread 5: MonthsName Thread 6: GetMonthsName Thread 7: TheMonthsName Thread 8: GetTheMonthsName

    What do I do for 9 and 10?!?

    Thread 9: GetNameOfMonth Thread 10: GetNameOfTheMonth Thread 11: NameOfTheMonth Thread 12: NameOfMonth Thread 13: ...?

    Thread 13: WhatMonthIsThis Thread 14: WhatMonthIsThis_Yo

  • (cs) in reply to Marc B
    Yeah, but I'm planning on running 10 simultaneous threads, and I'm running out of names:

    Thread 1: MonthName Thread 2: GetMonthName Thread 3: TheMonthName Thread 4: GetTheMonthName Thread 5: MonthsName Thread 6: GetMonthsName Thread 7: TheMonthsName Thread 8: GetTheMonthsName

    What do I do for 9 and 10?!?

    Don't worry, I've got you covered.

    function GetMonthName(thisNum)
    	'pared down to built-in function for brevity
    	GetMonthName = MonthName(thisNum)
    end function
    
    Dim i, j, funcName, code
    code = ""
    For i = 0 To 25
    	For j = 0 To 25
    		funcName = Chr(Asc("a") + i) & Chr(Asc("a") + j) & "GetMonthName"
    		code = code & vbCrLf & "Dim " & funcName
    		code = code & vbCrLf & "Set " & funcName & " = GetRef(""GetMonthName"")"
    	Next
    Next
    
    Execute(code)
    

    Now you have 26^2 versions of the function you can call, from "aaGetMonthName" to "zzGetMonthName".

    WScript.Echo aaGetMonthName(1)
    WScript.Echo wtGetMonthName(3)
    WScript.Echo fwGetMonthName(6)
    WScript.Echo zzGetMonthName(5)
    
  • Ancient_Hacker (unregistered)

    Could be worse.

    I've seen apps that do SQL lookups to get the name of the days of the week. Every time.

  • Sanity (unregistered)

    To me, the icing on the WTF is that "on error resume next" is in every single one of those. It seems to me to be a more naive form of this, in Ruby:

    begin
      ...
    rescue
      # do nothing
    end

    At least in that code, execution will drop out of the "begin" block on an error. My understanding is that "on error resume next" means execution will continue to the very next line.

    Can anyone explain to me where "on error resume next" would EVER be a good idea?

  • (cs)

    ' before adding more comments to this thread, consider ' the implications of including thousands of lines of ' classic ASP code in every page on your site...

    ' Don't know about you, but it gives me the willies...

  • (cs) in reply to Ancient_Hacker
    Ancient_Hacker:
    Could be worse.

    I've seen apps that do SQL lookups to get the name of the days of the week. Every time.

    Assuming the absence of the built-in VBScript function (and therefore the necessity of rolling your own), a string array of month names would work well:

    month = monthNameArray[mNum]

  • (cs) in reply to Mike H
    Mike H:
    function GetMonthName(thisNum)
        'pared down to built-in function for brevity
        GetMonthName = MonthName(thisNum)
    end function
    
    Sure would be nice to be able to do:
    #define GetMonthName MonthName
    
    for those cases, let the preprocessor sort out the ugly details.
  • (cs)

    See, I love to see that crap. It's a sign that I'm following a half-competent hobbiest, who doesn't know enough of the lingusitic scary tricks to leave good pitfalls.

    Nothing more entertaining than coming across a pitfall made by someone with sub-standard skillz...It's kinda cute actually. "Ooooh, da little coder thinks he hid his secret libraries, yes he does."

    Spend a day doing search-replace on the code base, and you'll have completely removed a problematic file, made the code more maintainable, and made so many changes you'll look like a god of productivity. It's win-win.

  • Joe Coder (unregistered) in reply to Sanity
    Sanity:
    To me, the icing on the WTF is that "on error resume next" is in every single one of those. It seems to me to be a more naive form of this, in Ruby:
    begin
      ...
    rescue
      # do nothing
    end
    At least in that code, execution will drop out of the "begin" block on an error. My understanding is that "on error resume next" means execution will continue to the very next line.

    Can anyone explain to me where "on error resume next" would EVER be a good idea?

    No.

  • (cs) in reply to LightStyx
    LightStyx:
    TheDailyWTF better start securing its code a little better than *wink*

    I agree...and FTFY.

  • rocksinger (unregistered) in reply to Razumny

    " Sing it with me:

    I love code'n'roll/so come on do recursion with me I love code'n'roll/so put another snippet in the GeneralFunctions yeah! "

    that's a WTF right there in so many ways - it does not scan, (still, that never bothered Rush...), recursion != repetition and the lines are the wrong way round for "I love rock and roll...."

    but hey, it's actually quite hard to make the thought fit - my best effort is still pretty dire...

    I love cut'n'paste/so put another dupe in the functions, baby I love cut'n'paste/so come an' take your code and paste with me...

  • Masm (unregistered)

    Except that the function already exists in VB, evidently no one wanted to rely on another programmer's code: what if the author of MonthName decided his function had to return the month names in dutch?

    Captcha: Aliquam (a lot of functions?)

  • (cs) in reply to Joe Coder
    Joe Coder:
    Sanity:
    To me, the icing on the WTF is that "on error resume next" is in every single one of those. It seems to me to be a more naive form of this, in Ruby:
    begin
      ...
    rescue
      # do nothing
    end
    At least in that code, execution will drop out of the "begin" block on an error. My understanding is that "on error resume next" means execution will continue to the very next line.

    Can anyone explain to me where "on error resume next" would EVER be a good idea?

    No.
    Yes! It is the first statement of your error handling block:

    'Boilerplate Sub Sub mySub On Error Goto mySub_Err ... Exit Sub

    mySub_Err: On Error Resume Next ...

    End Sub

  • Buddy (unregistered) in reply to Sanity
    Sanity:
    To me, the icing on the WTF is that "on error resume next" is in every single one of those. It seems to me to be a more naive form of this, in Ruby:
    begin
      ...
    rescue
      # do nothing
    end
    At least in that code, execution will drop out of the "begin" block on an error. My understanding is that "on error resume next" means execution will continue to the very next line.

    Can anyone explain to me where "on error resume next" would EVER be a good idea?

    In VBScript that's all you have.

    In other cases, you can put OERN in a single higher level main-like function, the lower level functions will exit on error, and you can check the results of each step in the higher level function. This allows for graceful recovery even of "really bad" errors.

    Also, using one OERN in a higher level function can be cleaner than setting up a whole lot of gotos and line labels.

  • (cs) in reply to AnotherAnonymous
    AnotherAnonymous:
    #1: Maybe the coder fell asleep while coding it?

    #2: Don't be ridiculous. If he had fallen asleep, he wouldn't have typed out "zz", he would have just snored.

    #1: Perhaps he was dictating.

    Aaaarrrrggghhh...

  • (cs) in reply to Sanity
    Sanity:
    Can anyone explain to me where "on error resume next" would EVER be a good idea?

    In VBScript. The only other option (which is the default) is "On Error GoTo 0", which makes all errors fatal.

  • (cs) in reply to Spectre

    Hence the reason that whenever I have been FORCED to use classic ASP, I always write it in Javascript. Thank the GODS you can still do that in IIS.

    Spectre:
    Sanity:
    Can anyone explain to me where "on error resume next" would EVER be a good idea?

    In VBScript. The only other option (which is the default) is "On Error GoTo 0", which makes all errors fatal.

  • 008 (unregistered)

    There's also On Error Resume (without the Next), which stupidly retries the erroring line in the hope that it's hitting a "natural" error (such as an I/O resource being unavailable) rather than an Error statement.

  • Pseudo Code (unregistered) in reply to Sanity
    Sanity:
    Can anyone explain to me where "on error resume next" would EVER be a good idea?
    print "Are you sure?" on error resume next read answer delete file

Leave a comment on “zzGeneralFunctions”

Log In or post as a guest

Replying to comment #:

« Return to Article