| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
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.
|
|
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.
|
|
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. |
|
Global search and replace is your friend.
|
|
The biggest WTF is the file name. Surely it should be zzGeneralFunctionsPluralZAlpha.
Skizz |
|
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.
|
Re: zzGeneralFunctions
2009-04-22 09:19
•
by
Single User
(unregistered)
|
It's for concurrency. If MonthName is already running in another thread, you can fall back on using GetMonthName. Clear as daylight. |
Re: zzGeneralFunctions
2009-04-22 09:20
•
by
monkeyPushButton
(unregistered)
|
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... |
|
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! |
I suspect that they copy-pasted it from some crappy website, and then someone else did exactly the same thing. |
|
Rats, I need to get the month name, but all in upper case. Guess I'm writing another function from scratch.
|
|
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. |
|
What would make this even better is if this was for the National Institute of Health (NIH).
|
|
First!!2
nothing like repeating what someone's already said |
|
It's like trying to recreate wheel. Except the wheel is lumpy, deformed, and irritatingly stupid.
|
'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 |
And also made of jell-o. |
|
I'll add this:
'Before writing a new function be really , and I mean really, sure that said function is not stupid, kkthxbye' |
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. |
Re: zzGeneralFunctions
2009-04-22 10:07
•
by
Marc B
(unregistered)
|
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?!? |
|
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!
|
|
#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. |
Re: zzGeneralFunctions
2009-04-22 10:20
•
by
Anon
(unregistered)
|
Thread 9: GetNameOfMonth Thread 10: GetNameOfTheMonth Thread 11: NameOfTheMonth Thread 12: NameOfMonth Thread 13: ...? |
|
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.
|
Why? |
TheDailyWTF better start securing it's code a little better then *wink* |
Re: zzGeneralFunctions
2009-04-22 10:25
•
by
ih8u
(unregistered)
|
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 |
Thread 13: WhatMonthIsThis Thread 14: WhatMonthIsThis_Yo |
Re: zzGeneralFunctions
2009-04-22 10:28
•
by
Scott
(unregistered)
|
Is it just a coincidence that Jeff @ Coding Horror has a blog post about just that? http://www.codinghorror.com/blog/archives/001257.html |
Don't worry, I've got you covered.
Now you have 26^2 versions of the function you can call, from "aaGetMonthName" to "zzGetMonthName".
|
Re: zzGeneralFunctions
2009-04-22 10:29
•
by
Scott
(unregistered)
|
|
Crap I suck.. http://www.codinghorror.com/blog/archives/001257.html
|
|
Could be worse.
I've seen apps that do SQL lookups to get the name of the days of the week. Every time. |
|
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 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? |
|
' 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... |
Re: zzGeneralFunctions
2009-04-22 10:40
•
by
Scott
(unregistered)
|
That's the equivalent of creating a Excel document in code to add two numbers and get the result. Wow. Reminds me of The FileSystemHashMapNotepadCalculator |
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] |
Sure would be nice to be able to do:
for those cases, let the preprocessor sort out the ugly details. |
|
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. |
Re: zzGeneralFunctions
2009-04-22 10:45
•
by
Joe Coder
(unregistered)
|
No. |
I agree...and FTFY. |
Re: zzGeneralFunctions
2009-04-22 10:50
•
by
rocksinger
(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! " 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... |
|
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?) |
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 |
Re: zzGeneralFunctions
2009-04-22 11:06
•
by
Buddy
(unregistered)
|
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. |
Aaaarrrrggghhh... |
In VBScript. The only other option (which is the default) is "On Error GoTo 0", which makes all errors fatal. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |