|
|
|
| Non-WTF Job: C++ Developer at Good Grievance (Ronkonkoma, NY) |
| « Prev | Page 1 | Page 2 | Next » |
Re: It Gets Worse Each Year
2008-06-18 08:03
•
by
Tim the Enchanter
(unregistered)
|
|
Magnificent!
|
|
For those who don't see the wtf, look at the parameters of this function:
http://www.cplusplus.com/reference/clibrary/cstdlib/itoa.html |
|
Did someone notice there was a constant defined as 10 and use that without considering that something called VERSION_CODE would probably change, or did they just define their own variable for this function but stupidly call it VERSION_CODE - whereupon subsequent coders incremented it, because they thought they should?
|
|
Fixed..
|
Re: It Gets Worse Each Year
2008-06-18 08:19
•
by
#define AUTHOR_NAME 13
(unregistered)
|
|
Sticking to the rule that magic numbers are bad, I propose that the code is fixed like this:
|
|
This is why you should always pay attention to context when doing a search/replace to get rid of magic numbers.
I guess they can't say that nobody writes WTFs in base 13. |
|
I look forward to when everyone uses hex in 2011.
|
|
Ah. An Honest WTF that is the real WTF.
Also, I like the AD at the top of the page: Non-WTF Job: Want a 30 inch monitor? Work for TripAdvisor (Newton, MA) Are we that easily swayed? COURSE NOT! Make it 32 and you have a deal. |
|
"This one goes to base 11"
|
|
One other possibility is that the original code had the 10 hardcoded there in the itoa. But ALSO that the real version code value "10" was also everywhere else in the code.
Then someone other (possibly an intern) refactor the 10s to replace them with VERSION_CODE for easier management of their version. Using a quick search/replace in the code base, you cause no trouble. Hey! its exactly the same code (possibly even byte-to-byte identical) just that 10s have now been replaced with VERSION_CODE. Thus, the WTF does not incumb to the original developer, but the one who refactor the code. If in the first place the orginal developper had use an ITOA_BASE_CONVERSION constant instead, it **might** have raised some alarms bells to read "#define ITOA_BASE_CONVERSION VERSION_CODE". But, that assumes the refactoring developper reviewed its changes. |
|
Really the original developer should have made this configurable, and used lots of words like 'Factory' to construct the numeric representations... that's the real WTF... if you're going to be configurable you may as well go all the way.
|
|
This reminds me of one bug I fixed which occurred on Wednesdays. The code was something like (it was in Java):
if((new Calendar()).get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) {
When I asked the dev who had checked it in, he said he was testing something & forgot to take it out. We still got a laugh out of it, though. |
Re: It Gets Worse Each Year
2008-06-18 08:57
•
by
Alan
(unregistered)
|
I was thinking the *exact same thing* Brilliant! |
Mine is already 32 inches! {Oh, I have a large monitor too} |
Re: It Gets Worse Each Year
2008-06-18 09:15
•
by
#define AUTHOR_NAME 13
(unregistered)
|
Mine is VERSION_CODE inches! (it gets bigger every year) CAPTCHA: eros (how did it know?) |
Re: It Gets Worse Each Year
2008-06-18 09:18
•
by
Anon.
(unregistered)
|
Nobody makes jokes in base 13. |
Re: It Gets Worse Each Year
2008-06-18 09:24
•
by
dave
(unregistered)
|
|
Don't be ridickulous.
|
You're planning on being alive for another 1839 years? |
|
I remember seeing this already. TRWTF is that you are lazy.
CAPTCHA: refoveo |
|
Well, found a nice function in the code I currently work with:
bool IsNegative(double value); I bet you can image how the body of that function looks. And somehow it is a member function and not even static. Well... better to be on the save side, perhaps the definition of negative may change! |
|
Looks to me like a Jr. developer, fresh out of "Magic Numbers Are EVIL! Take my word for it because I am a professor that never did any real software development" college, saw that "10" was used in the call to itoa(...), found a #define that matched it, and simply changed the 10 to the #defined value.
I have seen dumber things done to existing codebases... Capcha: dolor -- a dull color maybe? |
Re: It Gets Worse Each Year
2008-06-18 09:54
•
by
sysKin
(unregistered)
|
I bet the following: bool IsNegative(double value) { if (value < 0.0) return true; else if (value >= 0.0) return false; else return FILE_NOT_FOUND; { right? |
All your base 13 are belong to us! |
|
Look, the author of itoa was doing a good thing by conserving variables and re-using existing code instead of inventing a whole new variable to store the number 10. If you can't see that, then you just dont understand reusable programming.
The only WTF is the author of itoa did not put the required comment after the definition of VERSION_CODE, so future developers would know where it is used, like this: #define VERSION_CODE 10 //2005 // Used in the following modules: // xxx.c, line 105 // yyy.c, line 1498 // etc, you get the picture |
Re: It Gets Worse Each Year
2008-06-18 10:02
•
by
Doc Monster
(unregistered)
|
"Pain" in Spanish. |
|
I think you forgot to stamp "Best of the Sidebar" on this one.
http://forums.thedailywtf.com/forums/t/8491.aspx (Now let's brace ourselves, for another resurrected thread will pop up.) |
Re: This is reusable code
2008-06-18 10:10
•
by
nimis
(unregistered)
|
And you can't use the VERSION_CODE variable anywhere if it isn't commented before there. And as you're trying to modify a header, you can only edit it with permission from management. Please notice that you also need permission to insert a line below 1498 at yyy.c Long live to long lines! Anyway, it's still faster doing a search for VERSION_CODE, with the IDE sending you to the proper line, than manually going to line 105 of xxx.c |
Re: It Gets Worse Each Year
2008-06-18 10:14
•
by
Ozymandias
(unregistered)
|
|
Ad? What ad?
//Firefox+Adblock |
|
Isn't there an overload of itoa that doesn't take any base argument at all (and defaults to base10)? I mean, 9 times out of 10 that's what you want anyway?
|
Re: It Gets Worse Each Year
2008-06-18 10:33
•
by
Generic Phil
(unregistered)
|
That's very true; half the time I'm working in base 18. |
|
Wow, that's quite a gem. We need more stories like this.
|
I remember reading this already. You're an idiot. You're also a moron for quoting your CAPTCHA. |
Re: It Gets Worse Each Year
2008-06-18 11:01
•
by
real_aardvark
|
Pardon my anal fix, as they say. I didn't even know that there was a third parameter to itoa() in the first place. Why? Using itoa() at all is a bit of a WTF in itself. It's not like it does anything that sprintf() doesn't do (apart from print numbers in base 13, obviously), and it certainly does a lot less. I shudder to imagine an internationalisation wrapper around this thing that tries to deal with dates, currencies, and the like through repeated bludgeoning with an insane third parameter. |
Re: It Gets Worse Each Year
2008-06-18 11:04
•
by
real_aardvark
|
Well, ya gotta admit, it is pithy. You can admit that with a lisp, if you like. |
|
All your base are increment by us.
|
|
itoa() and ltoa() are non-standard library functions, and that is a real WTF. For portability reasons they shouldn't be used, as not all compilers support them.
|
Re: This is reusable code
2008-06-18 11:26
•
by
Mark
(unregistered)
|
I'd rather use xemacs and start a holy editor war! Give me: M-x grep VERSION_CODE $(find . -name "*.[ch]")or give me death^H^H^H^H^Ha really big monitor! |
Re: It Gets Worse Each Year
2008-06-18 11:26
•
by
A Nonny Mouse
(unregistered)
|
That's what SHE said! |
Screw that, I'd rather use vim. :!grep VERSION_CODE $(find . -name "*.[ch]") |
|
Funniest WTF I've read all year!
|
Re: It Gets Worse Each Year
2008-06-18 12:01
•
by
AssimilatedByBorg
|
I would have, 5 days ago, on Friday the 10th, if only I had thought of it at the time... :) |
Re: It Gets Worse Each Year
2008-06-18 12:03
•
by
foo
(unregistered)
|
I'll never make fun of... #define BASE_TEN 10 ... again. It is obviously armor plating the code against cow orkers. |
Re: It Gets Worse Each Year
2008-06-18 12:04
•
by
Bobbo
(unregistered)
|
Hey lay off, at least this one contains some code, and not just exciting stories about servers being used to run Quake. |
Re: It Gets Worse Each Year
2008-06-18 12:14
•
by
Nutmeg Programmer
(unregistered)
|
|
Do I understand that this program, whatever it is, gave wrong answers for 2+ years before anyone looked for a bug?
WTF! |
I've keep hearing about ads on the Internet too. Actually, this one is right under the logo and gets past Adblock for me, but isn't obtrusive so I don't care. I've actually unblocked ads for TDWTF at various times because of Beanbag Girl and Irish Girl. |
Re: It Gets Worse Each Year
2008-06-18 12:39
•
by
real_aardvark
|
Y'know, I worry about you. That's just me, I guess. Talk to your local pastor, and avoid psychiatrists and crossing the road. I know these things. |
Re: It Gets Worse Each Year
2008-06-18 12:41
•
by
real_aardvark
|
... |
Re: It Gets Worse Each Year
2008-06-18 14:30
•
by
Ilya Ehrenburg
(unregistered)
|
Could it be you should reconsider your notion of cause and effect? |
Re: This is reusable code
2008-06-18 15:30
•
by
AC
(unregistered)
|
True, as it's a macro. |
Re: It Gets Worse Each Year
2008-06-18 15:43
•
by
gruckiii
(unregistered)
|
That's what we call Canadian dollars eh. |
| « Prev | Page 1 | Page 2 | Next » |