A junior programmer (let's call him Luis) and I were working to find a particularly stubborn Heisenbug (a bug that seems to disappear when you attempt to study it) this last week, and it was kicking our collective butts.

This thing was just impossible to pin down: it seemed to only happen under very rare conditions, and no one on the programming or QA teams had been able to replicate those conditions exactly. We knew it was happening, though, because we kept getting similar complaints from our users. Because of these complaints, the bug was high enough priority that we needed to find it and kill it, but not high enough that it was our only task. We'd been working on it for a couple days, and we weren't any closer. Long story short: this bug was proving hard to squish.

Luis and I were doing a quick wrap-up on Friday afternoon so we could know where to pick up this bug hunt on Monday. Luis casually told me he'd take a look over the weekend to see if he could find out anything else. I immediately asked him not to do that.

He seemed puzzled, countering that it really wouldn't be too much trouble. I replied that he shouldn't worry about it; while I can't tell him what to do since I'm not his boss, I did express to him that I wouldn't be spending my personal time (e.g. weekends) working on company projects. That time is for me, not for the company.

I'm lucky in that this seems to be part of the culture of my workplace. Upper management expects you to spend 40 hours a week to kicking ass on company projects, and then go home and not do company things on the weekends.

What surprised me the most was that Luis wasn't told to work over the weekend, he volunteered. He wanted to do it. I asked him why he wanted to work on this over the weekend, and he told me that he just wanted an answer. We'd spent a lot of time and energy trying to track this down, and we hadn't gotten very far. Luis really wanted to just have the answer so we could justify all our effort.

What Luis didn't realize was that he was falling into the sunk cost fallacy, a term from economics that describes why you went to that baseball game you already bought tickets for even though you were sick and should have stayed home in bed. People are averse to loss, and admitting they've wasted time, money, or effort is one of the things people will do their damndest to avoid. Luis didn't want to admit having "wasted" time and effort tracking down this bug with nothing to show for it, and so he wanted to redouble efforts and spend more time tracking down something that had already consumed a lot of it.

Thing is, we didn't "waste" time at all. In the hours we spent searching for the bug, we eliminated quite a few alternative theories as to why it was occurring, and had narrowed down the code that was causing the bug to one of three different places in the (very large) codebase. We still didn't know precisely what was causing it, but we knew what wasn't, and that was something.

I told Luis that, if he really wanted to and had nothing better to do, he could try to continue the bug hunt over the weekend, but that I would advise against it. Too much time spent looking at code and being frustrated leads to burnout. Besides, do you really want to spend your personal time on something that benefits the company and not you? It wasn't like we'd get anything more than a "good job, guys" when we finally found the bug (not that we should; this is our job after all).

I don't know if Luis actually did any hunting over the weekend; I'll find out Monday. But I hope he didn't. We developers spend a lot of time poring over code in our regular jobs, and IMHO to do that in our free time of our own free will for something that doesn't directly benefit us or our family is madness.

What do you think, readers? Am I being overly cautious, or stepping over a line by making such suggestions? How do you deal with sunk costs and needing to know the answer? Let me know in the comments!