- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
zzFirst
Admin
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.
Admin
Admin
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.
Admin
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.
Admin
Global search and replace is your friend.
Admin
The biggest WTF is the file name. Surely it should be zzGeneralFunctionsPluralZAlpha.
Skizz
Admin
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.
Admin
Admin
Admin
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!
Admin
Admin
Rats, I need to get the month name, but all in upper case. Guess I'm writing another function from scratch.
Admin
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.
Admin
What would make this even better is if this was for the National Institute of Health (NIH).
Admin
First!!2
nothing like repeating what someone's already said
Admin
zzGetFirst
Admin
It's like trying to recreate wheel. Except the wheel is lumpy, deformed, and irritatingly stupid.
Admin
'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
Admin
Admin
I'll add this:
'Before writing a new function be really , and I mean really, sure that said function is not stupid, kkthxbye'
Admin
Admin
Admin
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?!?
Admin
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!
Admin
#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.
Admin
Thread 9: GetNameOfMonth Thread 10: GetNameOfTheMonth Thread 11: NameOfTheMonth Thread 12: NameOfMonth Thread 13: ...?
Admin
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.
Admin
Why?
Admin
Admin
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
Admin
Admin
Don't worry, I've got you covered.
Now you have 26^2 versions of the function you can call, from "aaGetMonthName" to "zzGetMonthName".
Admin
Could be worse.
I've seen apps that do SQL lookups to get the name of the days of the week. Every time.
Admin
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:
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?
Admin
' 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...
Admin
month = monthNameArray[mNum]
Admin
Admin
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.
Admin
No.
Admin
I agree...and FTFY.
Admin
" 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...
Admin
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?)
Admin
'Boilerplate Sub Sub mySub On Error Goto mySub_Err ... Exit Sub
mySub_Err: On Error Resume Next ...
End Sub
Admin
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.
Admin
Admin
In VBScript. The only other option (which is the default) is "On Error GoTo 0", which makes all errors fatal.
Admin
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.
Admin
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.
Admin