• Tim the Enchanter (unregistered)

    Magnificent!

  • Michael (unregistered)

    For those who don't see the wtf, look at the parameters of this function: http://www.cplusplus.com/reference/clibrary/cstdlib/itoa.html

  • Dave (unregistered)

    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?

  • (cs) in reply to Tim the Enchanter

    Fixed..

    //#define VERSION_CODE 10 //2005 //#define VERSION_CODE 11 //1564 //#define VERSION_CODE 12 //11B3 #define VERSION_CODE 13 //BB6
  • #define AUTHOR_NAME 13 (unregistered)

    Sticking to the rule that magic numbers are bad, I propose that the code is fixed like this:

    #define VERSION_CODE 13   //2008
    #define VERSION_CODE_OFFSET -3	//2005-2008
    
    itoa(typelib_version, sTypelib_version, VERSION_CODE + VERSION_CODE_OFFSET);
    
  • (cs)

    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.

  • corey (unregistered)

    I look forward to when everyone uses hex in 2011.

  • (cs)

    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.

  • (cs)

    "This one goes to base 11"

  • philibert (unregistered)

    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.

  • (cs) in reply to philibert

    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.

  • fountainer (unregistered)

    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) {
        // Set some variable
    }

    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.

  • Alan (unregistered) in reply to gabba
    gabba:
    "This one goes to base 11"
    I was thinking the *exact same thing*

    Brilliant!

  • (cs) in reply to NaN
    NaN:
    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.

    Mine is already 32 inches!

    {Oh, I have a large monitor too}

  • #define AUTHOR_NAME 13 (unregistered) in reply to ParkinT
    ParkinT:
    Mine is already 32 inches!
    Mine is VERSION_CODE inches! (it gets bigger every year)

    CAPTCHA: eros (how did it know?)

  • Anon. (unregistered) in reply to gabba
    gabba:
    "This one goes to base 11"
    Nobody makes jokes in base 13.
  • dave (unregistered) in reply to ParkinT

    Don't be ridickulous.

  • (cs) in reply to corey
    corey:
    I look forward to when everyone uses hex in 2011.

    You're planning on being alive for another 1839 years?

  • WTF? (unregistered)

    I remember seeing this already. TRWTF is that you are lazy.

    CAPTCHA: refoveo

  • Vollhorst (unregistered)

    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!

  • James R. Twine (unregistered)

    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?

  • sysKin (unregistered) in reply to Vollhorst
    Vollhorst:
    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.

    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?

  • (cs) in reply to Anon.
    Anon.:
    gabba:
    "This one goes to base 11"
    Nobody makes jokes in base 13.

    All your base 13 are belong to us!

  • Top Cod3r (unregistered)

    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

  • Doc Monster (unregistered) in reply to James R. Twine
    James R. Twine:
    Capcha: dolor -- a dull color maybe?
    "Pain" in Spanish.
  • (cs)

    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.)

  • nimis (unregistered) in reply to Top Cod3r
    Top Cod3r:
    #define VERSION_CODE 10 //2005 // Used in the following modules: // xxx.c, line 105 // yyy.c, line 1498 // etc, you get the picture
    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

  • Ozymandias (unregistered) in reply to NaN

    Ad? What ad?

    //Firefox+Adblock

  • James (unregistered)

    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?

  • Generic Phil (unregistered) in reply to James
    James:
    I mean, 9 times out of 10 that's what you want anyway?
    That's very true; half the time I'm working in base 18.
  • WC (unregistered)

    Wow, that's quite a gem. We need more stories like this.

  • (cs) in reply to WTF?
    WTF?:
    I remember seeing this already. TRWTF is that you are lazy.

    CAPTCHA: refoveo

    I remember reading this already. You're an idiot.

    You're also a moron for quoting your CAPTCHA.

  • (cs) in reply to Michael
    Michael:
    For those who don't see the wtf, look at the parameters of the itoa function
    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.

  • (cs) in reply to Spectre
    Spectre:
    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.)

    Well, ya gotta admit, it is pithy.

    You can admit that with a lisp, if you like.

  • mtu (unregistered)

    All your base are increment by us.

  • (cs)

    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.

  • Mark (unregistered) in reply to nimis
    Anyway, it's still faster doing a search for VERSION_CODE, with the IDE...
    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!
  • A Nonny Mouse (unregistered) in reply to real_aardvark
    real_aardvark:
    Pardon my anal fix, as they say.

    That's what SHE said!

  • (cs) in reply to Mark
    Mark:
    Anyway, it's still faster doing a search for VERSION_CODE, with the IDE...
    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!
    Screw that, I'd rather use vim.
      :!grep VERSION_CODE $(find . -name "*.[ch]")
  • foo (unregistered)

    Funniest WTF I've read all year!

  • (cs) in reply to Anon.
    Anon.:
    Nobody makes jokes in base 13.
    I would have, 5 days ago, on Friday the 10th, if only I had thought of it at the time... :)
  • foo (unregistered) in reply to NSCoder
    This is why you should always pay attention to context when doing a search/replace to get rid of magic numbers.

    I'll never make fun of...

    #define BASE_TEN 10

    ... again. It is obviously armor plating the code against cow orkers.

  • Bobbo (unregistered) in reply to Spectre
    Spectre:
    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.)

    Hey lay off, at least this one contains some code, and not just exciting stories about servers being used to run Quake.

  • 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!

  • (cs) in reply to Ozymandias
    Ozymandias:
    Ad? What ad?

    //Firefox+Adblock

    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.

  • (cs) in reply to A Nonny Mouse
    A Nonny Mouse:
    real_aardvark:
    Pardon my anal fix, as they say.

    That's what SHE said!

    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.

  • (cs) in reply to James
    James:
    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?
    ...
  • Ilya Ehrenburg (unregistered) in reply to KenW
    KenW:
    You're also a moron for quoting your CAPTCHA.
    Could it be you should reconsider your notion of cause and effect?
  • AC (unregistered) in reply to nimis
    nimis:
    And you can't use the VERSION_CODE variable anywhere

    True, as it's a macro.

  • gruckiii (unregistered) in reply to James R. Twine
    James R. Twine:
    Capcha: dolor -- a dull color maybe?

    That's what we call Canadian dollars eh.

Leave a comment on “It Gets Worse Each Year”

Log In or post as a guest

Replying to comment #:

« Return to Article