• (cs)

    Wait..."0" means "true"? I think that may be TRWTF.

  • (cs)

    Whoooosh..

    The sound of that WTF going over my head..

  • A-Nona-Mouse (unregistered) in reply to toth

    Never heard of "negative true logic?"...actually quite common in many hardware disciplines.

  • Drew (unregistered) in reply to Quango
    Quango:
    Whoooosh..

    The sound of that WTF going over my head..

    /*case GIS_NEEDLE_STATE_RETRACTED:*/ #define Kees (m_nlGISRetracted &= ~(1 << nIndex))

    /*case GIS_NEEDLE_STATE_UNKNOWN: */ #define Jan (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_INSERTED: */ #define Piet (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_ERROR: */ #define Diederick (m_nlGISRetracted |= 1 << nIndex)

    Besides the obvious bad practice of naming defined functions after people, rather than after what they do; Jan, Piet and Diederick are all identical.

  • tetsu (unregistered)

    Eighth. And I don't buy it. Too funny to be true.

  • Not THAT Alex (unregistered) in reply to toth
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.
    That's because it's using file-not-foundian logic.
  • (cs)

    Surely Legion would have been better than Hans?

  • deekay (unregistered)

    Hans niet goedkeuren van deze stomme code!

    Captcha: gravis (useless old sound card)

  • (cs)

    This is clearly better than my practice of naming all inline functions "Alex", "Jake" and "Mark"...

  • (cs)

    what the...

    WHY are three of them exactly the same? This code is just plain twisted no matter how I look at it; at least they had the decency to surround the macros with parentheses to avoid unexpected side effects.

    ... it's the four dutchmen of the codepocalypse

  • umpaloompa (unregistered) in reply to Drew
    Drew:
    Quango:
    Whoooosh..

    The sound of that WTF going over my head..

    /*case GIS_NEEDLE_STATE_RETRACTED:*/ #define Kees (m_nlGISRetracted &= ~(1 << nIndex))

    /*case GIS_NEEDLE_STATE_UNKNOWN: */ #define Jan (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_INSERTED: */ #define Piet (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_ERROR: */ #define Diederick (m_nlGISRetracted |= 1 << nIndex)

    Besides the obvious bad practice of naming defined functions after people, rather than after what they do; Jan, Piet and Diederick are all identical.

    Three out of four inputs return the same output. This may be true today, but perhaps the coder foresaw a need for that to change in the future.

  • J., another Dutchman (really!) (unregistered)

    No, one would need three Dutchmen to screw in a lightbulb (better be a large lightbulb... ;-), that's why the Hans solution will probably not work... Oh wait everyone's switching to LEDs these days...

  • Booboo (unregistered)

    You're complaining about functionality being duplicated?! That's hardly a WTF...

    I am trying to remember if I ever thought it was smart to make my code 'tidy' using macros like that as disguised functions, when I first learned about the preprocessor...

  • Merty (unregistered)

    Most of the times, you wonder how on earth something like this slips into the code. My guess: Poor programmer don't know what kind of errors there are and what to do with it and ask 4 people: Kees, Jan, Piet and Diederick. All came with a different solution. So, pragmatic as the programmer is, he implements all solutions but does make sure the 4 nitwits who advices him, do get blame forever in this code..

  • D (unregistered)

    So what? The names are stupid, and two macros (or functions) would suffice, but is it WTF-grade code? It looks like it is even working!

  • D (unregistered) in reply to kastein
    kastein:
    WHY are three of them exactly the same?

    I would guess that if the state is unknown or if there was some error it is safer to assume the needle is inserted than that it is retracted.

  • Stoker (unregistered) in reply to J., another Dutchman (really!)
    J.:
    No, one would need three Dutchmen to screw in a lightbulb (better be a large lightbulb... ;-), that's why the Hans solution will probably not work... Oh wait everyone's switching to LEDs these days...

    Many Hans make light work!

    Sorry, couldn't resist, it has been a slow day.

  • (cs) in reply to deekay
    deekay:
    Hans niet goedkeuren van deze stomme code!

    What crappy translator did you use?

    But what bothers me most is that I can't come up with a famous Dutch song or book or movie that has four characters named Jan, Kees, Piet and Diederick.... Jan and Piet share a song with Joris and Corneel, but these other guys are nowhere to be found in this WTF....

  • (cs) in reply to umpaloompa
    umpaloompa:
    Three out of four inputs return the same output. This may be true today, but perhaps the coder foresaw a need for that to change in the future.
    Because adding switch branches and defines as needed in the future is that much more obscure...
  • (cs)

    They went a step farther than one of my coworkers. He used to comment parts of his code like this:

    // ask david this->AllData2 = true;

  • Hans (unregistered) in reply to D
    D:
    So what? The names are stupid, and two macros (or functions) would suffice, but is it WTF-grade code? It looks like it is even working!

    Real WTF-code is always working in some fashion. It is the way it goes about its business that is the true source of WTF.

    And yes, my name really is Hans... And I'm doing the work of four people... And still finding time to post here ;-)

  • Lupus.Umbrae (unregistered) in reply to toth
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

  • Kevin (unregistered) in reply to umpaloompa

    Or, more likely, they used to be all different but now three are the same. If the programmer was smart enough to recognise it might change, he'd have been smart enough to do it a better way in the first place.

  • Eh (unregistered) in reply to Drew
    Drew:
    /*case GIS_NEEDLE_STATE_RETRACTED:*/ #define Kees (m_nlGISRetracted &= ~(1 << nIndex))

    /*case GIS_NEEDLE_STATE_UNKNOWN: */ #define Jan (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_INSERTED: */ #define Piet (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_ERROR: */ #define Diederick (m_nlGISRetracted |= 1 << nIndex)

    Besides the obvious bad practice of naming defined functions after people, rather than after what they do; Jan, Piet and Diederick are all identical.

    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    Looks to me that it's an attempt at a finite state machine. In that case the comments would refer to the current state and the functions would return the next state. I can't be bothered working out the states to see if I'm right.

  • Dylan (unregistered) in reply to Lupus.Umbrae
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    Strcmp returns (string1 - string2); how is that related to a state var that uses 0 for yes?

  • (cs) in reply to kastein
    kastein:
    WHY are three of them exactly the same?
    Because Jan, Diederick and Piet are clones. We just don't know if the original is one of them or someone else that was cut away from the project.
  • Jeremy (unregistered) in reply to Dylan
    Dylan:
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    Strcmp returns (string1 - string2); how is that related to a state var that uses 0 for yes?

    I think the comparison being made is that strcmp returns 0 if they are equal.

  • Anon (unregistered) in reply to Drew
    Drew:
    Quango:
    Whoooosh..

    The sound of that WTF going over my head..

    /*case GIS_NEEDLE_STATE_RETRACTED:*/ #define Kees (m_nlGISRetracted &= ~(1 << nIndex))

    /*case GIS_NEEDLE_STATE_UNKNOWN: */ #define Jan (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_INSERTED: */ #define Piet (m_nlGISRetracted |= 1 << nIndex)

    /*case GIS_NEEDLE_STATE_ERROR: */ #define Diederick (m_nlGISRetracted |= 1 << nIndex)

    Besides the obvious bad practice of naming defined functions after people, rather than after what they do; Jan, Piet and Diederick are all identical.

    Probably because Dutch labor laws make it quite difficult and expensive to fire somebody.

  • (cs) in reply to kastein
    kastein:
    ... it's the four dutchmen of the codepocalypse

    CoDepocalypse: When two co-dependent people finally break up, explosively.

  • sadwings (unregistered)

    Maybe when the code was first written, those functions were different in some way.

    If it was easier to change the macro definition instead of combining them into one and changing all of the calls, then there's your reason for doing so.

    Sometimes people do things because they deem one course of action "less risky" than others, and even though it may be wtf'ish, it's not a true wtf when that happens.

  • (cs) in reply to Jeremy
    Jeremy:
    Dylan:
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    Strcmp returns (string1 - string2); how is that related to a state var that uses 0 for yes?

    I think the comparison being made is that strcmp returns 0 if they are equal.

    It makes sense if you realize strcmp answers "What is the difference between the strings?"; not "Are the strings equal?".

    if (!GetDifferenceBetween(s1, s2)) ...

  • (cs) in reply to Lupus.Umbrae
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    strcmp() doesn't return a boolean...

  • Michael S (unregistered)

    And I thought I was bad for liberally using "steve" as a name for debug variables and functions...

  • Anonymous Coward (unregistered) in reply to Merty

    The real WTF is using - rather than ~ for negation. Let's have some fun by putting thenoriginal code on a one's-complement machine

  • Synchronos (unregistered) in reply to Merty
    Merty:
    Poor programmer don't know what kind of errors there are and what to do with it and ask 4 people: Kees, Jan, Piet and Diederick. All came with a different solution.

    And the next "Tales from Interview" article is born: You are walking along a mountain trail and come across a fork with four Dutchmen. You don't know where to head and you know only one of them talks a truth. What do you do?

  • (cs) in reply to RobFreundlich
    RobFreundlich:
    kastein:
    ... it's the four dutchmen of the codepocalypse
    CoDepocalypse: When two co-dependent people finally break up, explosively.
    Hey!
  • Mike (unregistered) in reply to toth
    toth:
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    strcmp() doesn't return a boolean...

    C doesn't have booleans. It uses ints where 0 is false and any value that isn't 0 is true. That means strcmp will return "false" when the strings are equal and "true" when they are not.

  • (cs) in reply to Mike
    Mike:
    toth:
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    strcmp() doesn't return a boolean...

    C doesn't have booleans. It uses ints where 0 is false and any value that isn't 0 is true. That means strcmp will return "false" when the strings are equal and "true" when they are not.

    I know. C's "booleans" aren't really booleans. But nevertheless, strcmp() returns an integer type result, not a boolean type result (even though there IS no "boolean" per se). Since it has three possible results, it cannot possibly be considered a boolean.

    And nor should it--strcmp() isn't "asking a question", so to speak. Does it make sense to say "Compare these two things. Yes or no?"? No, it doesn't. That's essentially what strcmp() is doing.

  • YonmaN (unregistered)

    Oh! I know these guys, they were the crew of the "Left Shifting Duchman". Har har.

  • Steve (unregistered)

    Many moons ago, I got the opportunity to rewrite a VB app where all the variables were either single characters or the names of the original author's friends and pets. If w = Bob Then ...

  • $$$ (unregistered) in reply to JavaJaap
    JavaJaap:
    deekay:
    Hans niet goedkeuren van deze stomme code!

    What crappy translator did you use?

    But what bothers me most is that I can't come up with a famous Dutch song or book or movie that has four characters named Jan, Kees, Piet and Diederick.... Jan and Piet share a song with Joris and Corneel, but these other guys are nowhere to be found in this WTF....

    I'm guessing this is a Government System?: http://en.wikipedia.org/wiki/Jan_Kees_de_Jager http://en.wikipedia.org/wiki/Piet_Hein_Donner http://en.wikipedia.org/wiki/Jan_Peter_Balkenende Piety we can't find Diedrick, though, maybe he retired already....

  • Really? (unregistered) in reply to Dylan
    Dylan:
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    Strcmp returns (string1 - string2); how is that related to a state var that uses 0 for yes?

    what strcmp returns is not defined that clearly. It only guarantees to return 0 if strings are the same, <0 if the first is lexically first, and >0 if the last is lexically first.

    Some(many/most/all) implementations may return s1-s2, but there is no guarantee of this. Point is, what the OP is saying is that strcmp returns 0 if two strings match - this is a little counter-intuitive. A function called 'copmpare' appears to return 'false' if two things match. Granted, there is (good?) reason for it, but nonetheless the point is well made.

  • Really? (unregistered) in reply to fourchan
    fourchan:
    Jeremy:
    Dylan:
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    Strcmp returns (string1 - string2); how is that related to a state var that uses 0 for yes?

    I think the comparison being made is that strcmp returns 0 if they are equal.

    It makes sense if you realize strcmp answers "What is the difference between the strings?"; not "Are the strings equal?".

    if (!GetDifferenceBetween(s1, s2)) ...

    Not sure which language it returns the difference in... Neither of the examples below (which I would assume are among the most common) claims to return the difference. http://www.cplusplus.com/reference/clibrary/cstring/strcmp/ http://us2.php.net/manual/en/function.strcmp.php

    Even wikipedia has an article on it.... http://en.wikipedia.org/wiki/Strcmp

  • (cs) in reply to toth
    toth:
    Mike:
    toth:
    Lupus.Umbrae:
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.

    When that is a WTF then strcmp() is a WTF, too...

    strcmp() doesn't return a boolean...

    C doesn't have booleans. It uses ints where 0 is false and any value that isn't 0 is true. That means strcmp will return "false" when the strings are equal and "true" when they are not.

    I know. C's "booleans" aren't really booleans. But nevertheless, strcmp() returns an integer type result, not a boolean type result (even though there IS no "boolean" per se). Since it has three possible results, it cannot possibly be considered a boolean.

    And nor should it--strcmp() isn't "asking a question", so to speak. Does it make sense to say "Compare these two things. Yes or no?"? No, it doesn't. That's essentially what strcmp() is doing.

    I'm pretty sure I've seen at least one C library where strcmp was implemented as returning the int (s1[idx_first_difference] - s2[idx_first_difference]), treating the characters as unsigned. This definitely returned a lot more than 3 results.

    That having been said, I've seen dozens of people other than me who've used its results as a boolean.

    Note that the primary justification I've seen for the Unix truth values (where 0 is true and everything else is false) is that there are generally a lot more ways things can go wrong than there are that they can go right.

    Note that I am a Perl programmer, at least partially because I believe everything should be a boolean, in addition to any other properties it may have.

  • (cs) in reply to Really?
    Really?:
    Not sure which language it returns the difference in... Neither of the examples below (which I would assume are among the most common) claims to return the difference. http://www.cplusplus.com/reference/clibrary/cstring/strcmp/ http://us2.php.net/manual/en/function.strcmp.php

    Even wikipedia has an article on it.... http://en.wikipedia.org/wiki/Strcmp

    Well, first, the example appears to be C or C++ and it seems most of us have been talking C, so I don't know why you're looking at PHP. Second, none of the URLs you provided indicate that it isn't the difference - they just leave it up to the implementer whether it is the difference, the numbers -1, 0, or 1, or something else. Note that it is easier to just use the results of subtraction, if it's not zero, rather than testing that in both directions to determine if it should be -1 or 1.

    That having been said, depending upon it actually being the difference would be a major WTF, because I'm pretty sure I've also seen at least one implementation which did return -1, 0, or 1. I think I've also seen an implementation which returned the difference of four bytes at a time, apparently with some code to sign-correct if it was a difference between the first two characters in that quartet.

  • Dan Covill (unregistered)

    The year: 1961 We were building a large system for a new Air Force contract. Being short-handed, we subbed a test analysis tool to another division of our company, which needed work.

    When it arrived, we glanced at the code. Like the Dutchmen, the programmer had made all the procedures names - Eric, Charley, Darlene, Shirley, ... But she went one step further. The arrays (all global, of course) were named Gin, Whiskey, Vodka, Rum, ....

    Dan Covill San Diego

  • David F (unregistered)

    Sounds like it was for a government agency, where it takes four near retirement age people to do the job of one normal person.

  • (cs)

    Sometimes when I'm in the mood I name my variables after my ex-girlfriends. Haven't run out yet.

  • Not always wrong (unregistered) in reply to toth
    toth:
    Wait..."0" means "true"? I think that may be TRWTF.
    There's only one way for a comparison to be true, but it can be false in many ways.

    Ever had a function that returns Zero when it succeeded? int Main() for example?

  • Dave (unregistered)

    Huh, they're not even appropriate dutchmen, they should have been Edsger, Guido, Henk, and Wietse.

Leave a comment on “The Four Dutchmen”

Log In or post as a guest

Replying to comment #:

« Return to Article