I got tired and debugged!
I got tired and debugged!
Posted by Uncle Bob on 12/20/2006
My grandaughter slept over last night. She’s an early riser. She and I had breakfast at 6am. My wife got a new cell phone (TREO680) yesterday, and I helped her set it up. So I didn’t go to bed until late. In short, I didn’t get a lot of sleep.
A bunch of us are working on a new training example for object oriented design principles and patterns. It’s a large-ish web-based system that has lots of interesting lessons to learn. We’ll be presenting it as a series of exercises throughout the course. Anyway, we’ve all been working as a team, writing this software. It’s been a lot of fun!
Anyway, about 3pm I started to get really tired. I should have stopped. But I wanted to finish one last story! (You know the feeling.) So I pressed on.
I ran accross a small dependency problem between two of the classes. So I started an elaborate refactoring to resolve the issue. An hour later I had to back out the whole refactoring because it didn’t solve the problem, or even come close! I don’t know what I was thinking. The real solution was much simpler and took just 10 minutes or so to implement. I should have stopped then, but, well, you know…
I needed to leave at 5pm. By 4:30 I was executing my unit tests. There was a problem. It didn’t make sense. You know the kind! I stared at the code for a long time, but my brain was mush. I couldn’t think. The lines of code swam before my eyes, but did not speak to me. I should have stopped then.
But no. Instead, I did something I barely ever do. Something I haven’t done in many months. I set a breakpoint! Egad! I was single-stepping through the code. And then I would do that horrible little dance where you step to a point in a module and realize you’ve gone a step or two too far. The variables don’t make sense. So you start over, and step back to just before where you were. Hideous! I should have stopped! But I kept at it. Over and over, breaking, stepping, breaking, stepping.
Debuggers feed you a torrent of information. Even when you are awake it’s easy to misread them. When tired, you see what you want to see, not what you really see. And nothing I saw made any sense. I finally got to the point where an if statement comparing two identical strings was failing! (Or so I thought.) I demanded that the stupid machine was lying. I rebuilt the application. I rebooted my machine. I redid the breakpoint, over and over. No change.
Now it was after 5pm. I really needed to go. I also really needed to fix this damned problem and check in the code. So I did the only thing that might make a bit of sense (other than stopping, which is what I should have done 2 hours before), I turned off the debugger and asked my pair-partner James for some help.
James had been busy helping one of the other guys get subversion working with Eclipse, so he’d been somewhat distracted while I was spinning myself into a debug rathole. He came right over and looked at my unit test. He said “Oh, shouldn’t that fravitz be a dorvitz?”
...
Duh. Yes, that fravitz should have been a dorvitz. It was obvious. It was simple. It was a 2 second change, and the tests all passed. (sigh).
So I, once again, reinforce my rule about debuggers. They are a horrible time-sink. When you find you must debug, it’s time to get help or go home.
Aaron Guan 19 days later:
Hello Uncle Bob,
It is really an interesting story about debugger. Sometimes, if you have an urge to use debugger, there must be some mess in your code, or you just get too tired to understand it.
But Uncle Bob, what does “fravitz” & “dorvitz” mean? Are they some kind of data structure in your code?
Robert W. about 1 month later:
I disagree.
John Lee over 3 years later:
Sometimes it is better to cut your losses, take off early and come back with a fresh mind. Its worked everytime for me and I was more productive afterwards.
Ray Cook over 4 years later:
At the very 1st, I’d prefer to state thanks to you for this enlightening post. 2nd, I’d prefer to doubt wheresoever I can determine a lot more data related to your article. I arrived right here through Yahoo and can not find out any linked up web websites connected to this matter. How do I sign for your web blog? I’d choose to stick to your updates as they arrive along! I had a query to interrogate but I forgotten what it absolutely was… anyway, thank you very much.
Criminal Records over 4 years later:
Debuggers feed you a torrent of information. Even when you are awake it’s easy to misread them. When tired, you see what you want to see, not what you really see.
Tenant Screening over 4 years later:
The lines of code swam before my eyes, but did not speak to me. I should have stopped then.
Seo Firm India over 4 years later:
Hi, i enjoy reading your website or blog. I got many ideas for my blog. Thanks for the info
hi good luck over 5 years later:
The pv energy system, developed, designed, engineered Solar Module and produced by Cenergy Power, addresses additional than four acres of soil in the Parlier complex.
hi good luck over 5 years later:
Our pv method will spend Multicrystalline Module for by itself in much less than five years,
hi good luck over 5 years later:
As component on the pv arrangement, additionally towards design, engineering Polycrystalline Solar Module and set up on the pv system