• your name (unregistered)

    took me some minutes, not the worst code I've seen. And the default age of 25 is reasonable assumption ;)

  • Quite (unregistered)

    If (gender == female) return 25;

  • dpm (unregistered)

    so glad to see he used string parsing on nBirth instead of nasty arithmetic operators / and %

  • Ron Fox (google) in reply to your name

    Those of us old enough know that a better default is 29, and that furthermore anybody older than 29 should be shown as being 29.

  • Obligatory XKCD reference (unregistered)
    Comment held for moderation.
  • isthisunique (unregistered)

    String structs are the way forward. Just serialise everything each function call to one param. It's awesomeness. Never had to write a function with more than one param since makes things so much simpler and is uniform with return. One in one out, one in one out, one in none out. Could not be simpler.

  • iWonder (unregistered)

    So I think this actually works correctly, it's just insane. My guess is at some point the birth date got "optimized" into an int and he didn't bother to rewrite all the old code for it. Or maybe I'm going too far down the rabbit hole here...

  • Steve_The_Cynic (nodebb) in reply to iWonder

    Frankly, I think you're so far down the rabbit hole, you're fifty miles up in the air on the other side of the planet.

  • Brian Boorman (google) in reply to iWonder

    Works correctly? Maybe - as long as the person isn't more than 99 years old. It's plainly broken in that case. But then again, that may be a limitation in the data source since the incoming integer looks to be representing MMDDYY digits.

    Addendum 2016-08-31 09:17: Edit: DDMMYY digits.

  • bvs23bkv33 (unregistered)

    i write such code every time

  • Steve_The_Cynic (nodebb) in reply to Brian Boorman

    MMDDYY or DDMMYY, it's the wrong way to position-encode dates in integers. Where I've seen position-encoded integer dates, it has always been YYYYMMDD, or converted in to a proper serial number. YYYYMMDD and serial numbers both allow you to sort unambiguously by date using the integer representation directly.

    But a proper date type is better, obviously.

  • CarrieVS (nodebb) in reply to Steve_The_Cynic

    So that's how they got to Australia.

    [joke intended for a European audience. Other locales' results may vary]

  • Otto (unregistered)

    Why 25 ? Always return 42 !

  • Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)
    Comment held for moderation.
  • Joseph Osako (google) in reply to isthisunique

    struct-based currying! I like the way you think!

  • CoyneTheDup (nodebb)

    I love this routine. According to it, I'm 25!

  • Norman Diamond (unregistered)
    Comment held for moderation.
  • AstorLights (google)
    Comment held for moderation.
  • PWolff (nodebb)

    Darn it. I only learned today, when I fed Google Translator with this article and read its [s]shit[/s]output, that "environment-aware" refers to ecology, and not some shell environment variable set.

  • Steve_The_Cynic (nodebb) in reply to PWolff

    Not Surprised.

    I know you're poking fun, but of course it shows the folly of context-free statistical machine translation.

  • AstorLights (google) in reply to Steve_The_Cynic

    True "environment aware" programmers use and reuse only global variables.

  • No Name here (unregistered)

    I once found

    if ( x --> y) { ...

    in C++ code. Took me a minute to figure out what that was doing...

  • Falco20019 (unregistered) in reply to Anonymous') OR 1=1; DROP TABLE wtf; --

    I really like your user name :)

  • Falco20019 (unregistered) in reply to No Name here

    And how long did it take you do find out why x was 1 less in the following code?

  • Brian Boorman (google) in reply to Steve_The_Cynic

    No arguments from me. Yet, if that's what the data source is feeding you, and you don't control the source, then I guess you're kind of stuck.

  • Steve_The_Cynic (nodebb) in reply to No Name here

    Another classic would be x+++y - without looking up the rules, how does the C/C++ parser read that? (Yes, I know the answer...)

    And I've seen x == y ? a = 7 : 0; (paraphrased, but it was "condition question-mark assignment colon zero") in the "if" branch of an if-else. Lazy fucker.

  • Lazerbaems (unregistered)

    YOU GUYS, the return 25 is not a default age, but rather an error code that is returned if the passed birthday is incorrect. The function assumes (correctly, no doubt) that the birthday is being read from a floppy disk, and therefore if the birthday is not able to be parsed then it's because the floppy disk is corrupted. So the function returns ERROR_SEEK.

  • Norman Diamond (unregistered)

    Another classic would be x+++y - without looking up the rules, how does the C/C++ parser read that? (Yes, I know the answer...)

    It doesn't. That would be like Toyota naming their premium brand Parsus instead of Lexus. Who would want to drive a Parsus, always following behind a Lexus and forced to eat entrails handed down from those who went before?

    Reminds me of dmr's inane Usenet posting where he asserted that whitespace is your friend. I retorted that if C programmers liked whitespace, he wouldn't have had to change the =- operator to -=

    Anyway, the lexer is frist.

  • random (unregistered)

    The real WTF here is that syntax highlighting used on DailyWTF apparently treats everything after a semicolon as a comment, even with C(++).

    (Yes, one shouldn't include multiple statements in a single line. But isn't this the site for "just because you can, doesn't mean you shou... no wait, do just that!" type of code.)

Leave a comment on “"Performant" ""Development""”

Log In or post as a guest

Replying to comment #:

« Return to Article