• NoLand (unregistered)

    If this were the first post, I'd mention, "first", else, provided this were a comment and I actually wrote it, i'd rather juster utter, "I wrote a comment."

  • Derp (unregistered)

    I dispute the claim that that works. If e.FormTreeNode is null it should fall over at the first conditional.

  • guest (unregistered)

    I don't know about this code sample, but I've worked with people as described in this article. Back when I was green, a senior person was helping me fix some code that was calculating freight incorrectly. They told me how to change the code, I did, then we ran a test and checked the results. After a few repetitions I realized they were just guessing, and trying to see if they could make it produce the right answer. I kicked them out of my cube and found the root problem on my own.

  • Anon (unregistered) in reply to guest

    Sounds like TDD.

  • I'm not a robot (unregistered) in reply to Derp
    If e.FormTreeNode is null it should fall over at the first conditional.

    And do you have any evidence that it ever could be null?

  • getwiththetimes (unregistered)

    I have no question that this blog purposely adds tons of errors to posts, just to incite comments. This post is basically a code block between two sentences, and the first sentence barely makes sense.

  • guest (unregistered) in reply to I'm not a robot

    The code is checking to see if it is null (which I think counts as evidence that it could be null), but only after it has already tried to dereference it earlier - which would have failed.

  • (nodebb) in reply to Derp

    If e.FormTreeNode is null it should fall over at the first conditional.

    But if it is never called with a null e.FormTreeNode, it's not actually important to test for that case.

  • guest (unregistered) in reply to guest

    That only counts as evidence that it was once null, so someone added that condition, and then later someone added the first condition because e.FormTreeNode is no longer null, without considering the function as a whole - this is how "simulated congealing" tends to happen

  • D-Coder (unregistered) in reply to Anon

    Sounds like TDD.

    More like ADD.

  • D-Coder (unregistered)

    This is a debugging technique that I call "beating the code into submission." But usually it includes random indentation, badly-named variables, and commented-out non-working versions.

  • I'm not a robot (unregistered) in reply to guest
    That only counts as evidence that it was once null
    Even that's optimistic, given the overall quality of the code.
  • Carl Witthoft (google) in reply to Derp

    If a FormTreeNode falls over and there's [nobody to hear]^W^W^W no code to catch it, does it make a [ sound]^W exception?

  • DigitalDan (unregistered)

    Gets paid by the line.

  • Steve W (unregistered)

    No, no, no. It's obvious. The coder had just learned about race conditions and is protecting against another thread modifying the content of e at the wrong time. Everyone knows that this is the correct way to handle it... What?

  • Mr. AHoleDBA (unregistered)

    So THAT'S what the source code for the SQL Plan Query engine looks like when it estimates a good enough plan to pick based on statistics!

  • Karl Bielefeldt (github) in reply to Anon

    Well, this is TDD if you leave off the refactor step of red-green-refactor.

  • TheCPUWizard (unregistered)

    Writing "just enough code" that it works is a very powerful STEP, but it is just a step... Remember Red [Test Fails], Green [Test Passes], Refactor [make the code better without breaking it]. It is the failure of the third step that is the problem, not the existence of the second.

    As far as the partial null, it is not so much that they needed to test that for the first part (though it certainly would be a good idea), but that there was a necessity to test it because of the latr conditional pass. Writing the test to check the flow at the bottom would have revealed the poor construct at the beginning.

  • Angela Anuszewski (google) in reply to getwiththetimes

    Um, that's the definition of a CodeSOD. You must be new here.

  • Derp (unregistered) in reply to I'm not a robot

    Can you guarantee it won't be?

  • Awesome (unregistered) in reply to guest

    Wow you are so awesome.

  • I'm not a robot (unregistered) in reply to Derp

    If it could be null, the code wouldn't work. The article claims the code does work. Therefore, unless you're suggesting that the article is lying (and if so, on what grounds?), it can't be null.

  • Ron Fox (google)

    This is actually Adiabatic programming (or rather Adiabuggic programming) Making small changes to the system while holding the total number of bugs constant.

  • Derp (unregistered) in reply to I'm not a robot

    I'm not sure if you're trolling here or just stupid. There's no way of knowing what gets passed in without checking it within the code. You cannot ever possibly guarantee it won't be null.

  • Yevhenii (unregistered)

    You encounter this method on a daily basis if you are a CS teacher/professor/TA/LA/etc. :-(

  • I'm not a robot (unregistered) in reply to Derp
    There's no way of knowing what gets passed in without checking it within the code.
    Maybe... just maybe... the submitter did that before claiming that it works? Of course we can't be sure of that, but it's not sensible to just randomly disbelieve the article for no reason. Presumably you trust it enough to believe that this is a real snippet of code in the first place, because if it wasn't then e.FormTreeNode being null or not would be moot.

    Not to mention, why are you just picking on e.FormTreeNode? e itself could be null, or any of the properties or methods used might throw exceptions when accessed/called. Or maybe they don't exist at all, and the code won't even compile. Or maybe it's actually supposed to be Lisp code, and the whole thing's just a giant syntax error. Speculating on any of those without evidence is pointless.

    I'm not sure if you're trolling here or just stupid.
    I, on the other hand, am sure that you are both trolling AND stupid.

Leave a comment on “Simulated Congealing”

Log In or post as a guest

Replying to comment #465849:

« Return to Article