• Dan Wiebe (unregistered)

    Hi! I'm Dan.

    How many of you have had an article published on this site?

    This is my second. One thing I've discovered is that between what you send in and what appears, there's some pretty heavy fictionalization going on. Sometimes it makes the story funnier or more incisive; sometimes it emphasizes the point the story was supposed to make. Sometimes, though, it really screws things up.

    In the original story, there was no Vince. There was just a team of developers diligently trying to follow the Boy Scout rule--leave the code better than you found it. I didn't use the VCS's blame command to find out who did it, but I wouldn't be surprised if it was a different person each time.

    Oh--and in answer to one issue that came up: yes, it's important that the preview image didn't participate in business-equals. Every time you save a Dashboard, a thumbnail image is computed. If one of the little thingies on the Dashboard is displaying a different number or picture than it was displaying last time that Dashboard was saved--a virtual certainty--the image will be slightly different. It's the number, nature, and positions of the little thingies on the Dashboard that should determine business equality, and those things were already being checked with the existing Equals method.

    Here's the original story I sent in.


    We had a class in our project called Dashboard that--well, it doesn't matter what it did, other than that it displayed a bunch of stuff on the screen. It had a business-equals method so that we could compare two dashboards and see if they were the same.

    We decided to add a data field to our Dashboard class to hold a preview image--sort of a thumbnail so that folks could look at a whole bunch of Dashboards in a list and get a rough idea what they'd look like on the screen without having to let them actually take over the screen.

    Now, the preview image shouldn't participate in the business-equals method, because there are a whole lot of ways the preview images for a couple of Dashboards could be minutely different even if the Dashboards themselves were exactly the same. So when I added the preview image, I specifically didn't change the business-equals method.

    But a guy who was reviewing my code got hold of me and said, "You forgot to add the preview-image field in the business-equals method." So I explained to him that it didn't belong there.

    "Ah," he said, and added a comment to that effect in the existing business-equals method. "Don't add a check for previewImage equality here, it doesn't belong," and like that.

    So a week later we were getting puzzling failures in the application--not the tests--and I traced them back to the business-equals method on Dashboard, where somebody had added--right under that comment--a comparison for previewImage. Just cleaning up the code, you see, trying to leave it better than he found it, noticed something missing and slapped it in. Didn't pay any attention to the comment, because (of course!) comments can generally be presumed to be obsolete and misleading.

    So I took out the check and the comment, and instead added a new test that created two Dashboards that were alike in every way except that they had different preview images, and asserted that the two of them were business-equal. The test had a nice intention-revealing name, like previewImageShouldNotParticipateInBusinessEquals.

    Everything was fine for a week, and then we began getting puzzling failures in the application--not the tests--again. I went to Dashboard and found the check for previewImage in the business-equals method again. I goggled, and went and found my special test. It was still there, but the assert-true had been changed to an assert-false to make it pass.

    Argh!

    So I fixed everything, and then in that test, further down, I added another--fairly obscure--assertion that the two Dashboards with the different preview images were equal, where it could only fail if the assertion before it had been changed, and in that assertion I put one of those special explanatory strings that gets printed to standard output when an assertion fails: "You frickin' pantload, you didn't even frickin' read the frickin' name of this frickin' test, did you? Put down that frickin' mouse right now and call me immediately at 123-456-7890!"

    It's been a couple of months, and I haven't gotten any calls, but we haven't gotten any more puzzling failures in the application but not the tests since then.

  • Dan Wiebe (unregistered) in reply to Ben Cooke

    The problem with comments--at least in this case--is that they weren't read by any of the people who made the bad changes. That's my general reflex as well. As an ancient developer with many years of history behind me, I've been burned so many times by obsolete comments that I pretty much ignore them these days unless I have reason to know that they are extremely recent. And sometimes even then.

    I'd much rather look at the code to find out what's going on, even if I have to navigate all over the place to find the code. Modern IDEs usually make that pretty simple.

    Anyway, to somebody who doesn't read comments, it doesn't matter what's in those comments.

    I think the transition from comment to automated unit test was an improvement, although in this case even that didn't dissuade somebody from doing what he thought was correcting an error: it took a honeypot followed by a deliberately offensive error message. I expect that message has been seen once or twice, and the change that prompted it then quietly Ctrl-Zed away.

    So far that's worked, but it shouldn't be necessary, sez I.

  • Moonraquel (unregistered) in reply to Dan Wiebe
    Dan Wiebe:
    One thing I've discovered is that between what you send in and what appears, there's some pretty heavy fictionalization going on. Sometimes it makes the story funnier or more incisive;

    Are we talking about thedailywtf.com here?

  • Norman Diamond (unregistered)

    That's the place where no one reads the comments (before adding their own of course).

  • Buddy (unregistered) in reply to Severity One
    Severity One:
    Andrew:
    When I was a kid, my dad was the only one who said the word "dashboard". It was always in reference to some acquaintance of his that had a horrific car crash. And it was always horrific, always the dashboard, and it happened about every month or two. So to me, it's the thing that you bang your head against when you leave a vehicle.

    Thanks to my dad, "dashboard" is a bad word.

    I mentioned this to him about a month ago, and he added that it is often the thing you hit on the way into the vehicle.

    I'm struggling to think how on earth you manage to hit the dashboard with your head when either entering or exiting the vehicle. Isn't the dashboard where are the little dials and blinkenlights are?

    Dad probably drives a late model big-ass American four door sedan. These had real dashboards that protruded well into the cabin with a handy shelf with a big steel wire perfectly aligned with your face should you be wearing the lap belt and in an accident, or just braking hard.

  • Captain Oblivious (unregistered) in reply to Jon Kalb
    Jon Kalb:
    The WTF here is Dan's. "Equals" is a term of art that has been in used for centuries before the invention of modern computers. If Dan has need for a concept that is similar too, but not exactly "equals" he should use a term that reflects this. Perhaps "BusinessEquals." But creating a function called "equals" that isn't defined to do what "equals" implies is a WTF asking to be corrected.

    I have to disagree with you here. "Equals" has been used for centuries, but the notion of equality is not unique, even in mathematics. Equality (as a predicate) is always computed relative to some equivalence relation, and there are typically many equivalence relations for any structure (there is one for every quotient on the structure).

    And this is ignoring "philosophical" issues like Liebniz versus other notions of equality.

    That said, the WTF is that two distinct notions of equality are in play on a single type. A new type should have been made to reify the distinct notions.

  • Norman Diamond (unregistered)

    Some definitions of equal are more equal than others.

  • Zikan (unregistered)

    "Since insanity is doing the same thing and expecting different results[...]"

    Hahaha, my favourite quote from a WTF and the only explanation why that guy did the same mistake again and again. Personally, I would quit the job with a bang, first asking that guy directly whether he was dropped on the head as a child and then beat him up.

  • Pluvius (unregistered) in reply to Chris
    The moral of the story: Don't put something on your resume unless you actually know it.

    Such as "I know Subversion."

  • Mike (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    So, what Dan forgot to use was some sort of punishment tool, like Mr Bat or Mr 9mm or maybe Mr O'Ninetails or Mr Claymore (mine or sword, your choice).

    He also forgot, it seems, to ask Vince why he kept adding the preview image to the Equals method. If he had, he would have learned the blindingly obvious - Vince wants to get rid of Dan, but they aren't in an at-will state, so he has to get Dan to leave.

    Presumably, Dan's replacement would be a cheaper-to-pay junior, even though the diminution in salarybill would be much less than the loss in productivity.

    Never heard of the sword. And if you use the mine, make sure the side that says "Front towards PHB" is pointed in the correct direction.

  • Anthony Steiner (unregistered)

    Did he GLV? lol He must have in order to get the hand slap assert error message... how can superiors be given the title if they're 9 times out of 10, NOT! You know what that's called? Laymen with a degree...

  • Salagir (unregistered)

    "Since insanity is doing the same thing and expecting different results"

    No, it's not, it's never been.

    It's not because you've read it on the internet that it's true. It's now because Scott Adams said it several times that it's true.

    People, stop using this catchphrase : it's wrong.

    Insanity is not that. And that, isn't insanity.

    You're intelligent people. If you think about it for a few seconds, you'll see that this assertion is false, in both directions.

    insanity => doing the same thing and expecting different results You've seen insane people? In real life, in movies? Were they doing the same thing over and over again EXPECTING different result? Have you even seen that, Did anyone tell you about such behavior? I'm not a doctor but I've actually asked one, a psychologist about it : she never heard of this "same thing" about insanity. Ever.

    doing the same thing and expecting different results => insanity You've done in your life the same thing, thousands of times, and different results happened. And most of the time, you were expecting it. Hit something several time, at some point, instead of staying in shape it will break. Restart your computer 3 times, and suddenly it'll work. Yell the same thing 5 times and at the 5th the other guy will finally hear it. Eat just one cookie : you're still hungry. Do the same thing 3 times, you're content. Do the same thing 38 times, you get ill.

    People, stop using this catchphrase : it's wrong. Thank you.

    Oh it feels good to finally say it !!

  • airdrummer (unregistered) in reply to Chris

    ijwtk why the dev didn't immediately take the evidence to his manager's manager & have the fukker fired, or @least kneecapped;-}

Leave a comment on “Equals”

Log In or post as a guest

Replying to comment #:

« Return to Article