• Wharrgarbl (unregistered)

    Not sceond uncomment

  • Jaloopa (unregistered)

    This post is not unamusing

  • Prime Mover (unregistered)

    Yeah, right.

  • Michael P (unregistered)

    The real WTF is why, given that the original code can only set portUnAvailable to False, code that can set it to True is presented as equivalent.

  • Artoooooor (unregistered)

    The title is great :D "Never Don't Stop Not Doing This" -> "Never Don't Start Doing This" -> "Always start doing this"?

  • (nodebb) in reply to Artoooooor

    "Don't stop" doesn't generally mean "start", it more often has the meaning of "continue". But the point is well taken. Did Remy intend to over-negate or did he just get tripped up?

  • (nodebb)

    NOT the same code....

    The first snipped can only set the existing value to false.... the supposedly "easier" can cause a value which was previously false to become true.

  • Chris (unregistered)

    I know that the suggested fix isn't exactly the same, but I'm guessing whoever wrote the original code was so confused that the fix would actually be correct.

  • Mister Tea Ae (unregistered)

    TRWTF is that he used Python, which even allows such constructs, instead of the vastly superior Microsoft.NET Framework, which is superior in every way. My brain is very smart and my mother definitely loves me.

  • (nodebb)

    It does look a bit over negated.

    Never Don't Stop Not Doing This => Always Do Stop Not Doing This => Stop Not Doing This => Carry on doing this.

  • Michael Scarn (unregistered)

    There's an application I "inherited" that uses a boolean env variable called "DO_NOT_USE_CACHE". I always have to think a little longer whenever I want to toggle cache behavior.

  • Ross Presser (unregistered)

    Could also have used "If port Is Not Nothing". "x Is Not Nothing" is a Visual Basic idiom meaning exactly "Not (x Is Nothing)"; it isn't trying to negate the truthiness of Nothing.

  • Smithers (unregistered) in reply to jkshapiro

    "Don't stop" would mean "continue," but that's not the part Artoooooor replaced. Their replacement was "stop not doing" to "start doing," which sounds right to me.

  • Rob (unregistered)

    Am I the only one that's annoyed that it's not called portUnavailable? Because last I checked, the word is "unavailable" and not "un available" or "un-available".

  • Prime Mover (unregistered)

    There is sometimes a good use case for negative logic.

    I remember an application which produced a generic report for a whole bunch of customers, customisable in various ways.

    One day we were given a requirement for one particular customer for which we were not to include a specific section. In order to implement the minimal change which did not involve hardwiring the customer's ID was to expand our registration database to include a new flag. The default behaviour, for customers who did not include that flag, was for that section to be generated. If the flag was set, the section was not included.

    Hence the need to negative logic: the flag was true in the case of "don't include X section".

  • A. Glez. B. (unregistered)

    In japanese if you ask someone "Did you not see this?" and the answer is "Yes" they literally mean that they did not see whatever you're asking about. So learn a bit of japanese and this will stop looking weird to you.

  • Daniel Orner (github) in reply to Prime Mover

    When I have to deal with things of that nature I tend to name the flag "skip_x" which makes it a bit more obvious that it powers the removal of some kind of logic or content.

  • rbh (unregistered) in reply to TheCPUWizard

    But let's assume that's not how this works, because that hints at a bigger WTF

  • (nodebb) in reply to Prime Mover

    Hence the need to negative logic: the flag was true in the case of "don't include X section".

    Should still have been positive logic: "exclude X section".

  • (nodebb)

    Clearly Visual Basic is lacking an Is Something operator.

  • (nodebb)

    Reframing the question to be positive logic is usually worth doing, especially if tests done on the flag are frequently of the "double negative" type (for clarity, the example code uses keywords rather than C/C++ operator symbols):

    if ( not don't-include-X ) produce-X

    becomes:

    if ( not exclude-X ) produce-X

  • (nodebb) in reply to Ross Presser

    Isn't Visual basic IsNot a single keyword? Also, I'm not 100% sure it existed from the start -- perhaps it was added after the first version of VB.Net?

    Also, the correct code would be something like portUnAvailable = portUnAvailable And (port is Nothing). And I don't care whether the parentheses are truly necessary or not.

  • (nodebb)

    The effect of the code in the article can be achieved with the assignment

    portUnavailable = portUnavailable and (port is nothing)
    
  • Jim Jam (unregistered)

    This is the reason why I usually suggest avoiding negations in variable/method names. If Not portIsUnAvailable requires much more cognitive effort to parse than If portIsAvailable

  • cellocgw (unregistered)

    Over in MathematicsLand, " x is positive" and "x is not negative" are in fact different conditions. Then again, how many of you software jocks have ever stopped to consider that " if x <= y" is really shorthand for "if x < y || x ==y " ?

  • Yikes (unregistered)

    I'm really trying hard to imagine a scenario where you have a port, which could actually be Nothing, but you need to keep track of whether it's available or not... I'm guessing there's way too much intertwined logic in these functions.

  • John (unregistered)

    Regarding the above report flag as a general example, my suggestion is thus:

    The flag is documented as "exclude-report", default is to be "off". Then as soon as the flag, along with other options, is read the program reverses the flag so that the internal logic uses "if include-report ..."

  • Yikes (unregistered)

    Also, suggested title update: Never Don't Stop Not Doing Nothing Unlike Something Other Than This

  • (nodebb)

    My favorite is still SQL Server's NOCOUNT property.
    SET NOCOUNT ON
    Means don't provide counts. It would be much more intuitive to have SET COUNT OFF for such a case.

  • whizzdome (unregistered) in reply to Artoooooor

    I couldn't fail to disagree with you less!

    [Credit to Raymond Smullyan]

  • Barry Margolin (github) in reply to Mister Tea Ae

    It's not Python, it's Visual Basic.

  • Fworg64 (unregistered) in reply to cellocgw
    Comment held for moderation.
  • Barry Margolin (github) in reply to Yikes

    It seems like it's used after you call a function that returns a port number, and if it can't it returns Nothing, then we set a boolean to remember whether it was successful and it's OK to use the port. I guess code that checks the PortUnAvailable variable could just check Port directly, but some programmers like to have a simple boolean that caches the test.

  • (nodebb)

    Nobody isn't never going to write no code unlike this, nowhere and for no reason.

  • (nodebb)

    There are some languages in which it's quite normal to chain multiple negations together, half a dozen or more in the same sentence. As a speaker of one of those languages, I still can't understand that code without writing down an explicit simplification.

  • v2itsolutions private limited (unregistered)
    Comment held for moderation.
  • (nodebb) in reply to Auction_God

    "My favorite is still SQL Server's NOCOUNT property. SET NOCOUNT ON Means don't provide counts. It would be much more intuitive to have SET COUNT OFF for such a case."

    The flip side is the concept that the default for all options should be OFF, and you explicitly need to turn options ON

  • (nodebb)

    Has Anyone Really Been Far Even as Decided to Use Even Go Want to do Look More Like?

  • Officer Johnny Holzkopf (unregistered) in reply to Mr. TA
    Comment held for moderation.
  • brass_phoenix (unregistered) in reply to Michael P

    They don't actually present it as equivalent. Note the sentence immediately after the fragment saying: "Then again, without context, that might be wrong".

  • Neveranull (unregistered)

    I wish I did not see this.

  • Joe Blow (unregistered)
    Comment held for moderation.
  • SyntaxError (unregistered)
    Comment held for moderation.

Leave a comment on “Never Don't Stop Not Doing This”

Log In or post as a guest

Replying to comment #:

« Return to Article