No joke, pen and paper, preferably a small notebook with no lines. One time I solved a very complex circular dependency issue this way. I think just writing down thoughts and process in a very human way can help with technical issues.
Ask HN: How do you get better at debugging/finding a solution?
41–50 of 83 posts
Re: Ask HN: How do you get better at debugging/finding a solution?
#42Re: Ask HN: How do you get better at debugging/finding a solution?
#43Use version control. If the order processing worked last week and johnny made a change to order processing in this release it's highly likely it's johnny's change.
You make an assumption of where the problem is and start looking. Always understand your assumption can be wrong and you are looking in the wrong place.
Avoid code with side effects. I've taken code with bugs in it and completely rewrote all of it without side effects just to avoid those types of bugs and magically all of the hard to find bugs disappeared.
Re: Ask HN: How do you get better at debugging/finding a solution?
#44I've mostly worked alone as a developer. No-one is going to fix it but me. Actually I think I enjoy problem solving more than the actual programming. Though frankly programming and problem solving are so closely related they are almost the same thing. I can solve most problems I come up against day to day. I guess I can't solve them all because I do ask questions on Stack Overflow sometimes. I'm not sure why, I guess…
Came here to say versions of 4 & 5. As a more junior programmer, I would sometimes resist the perceived effort or inelegance of the divide-and-conquer approach and end up spending much more time than needed to get to a solution.
Re: Ask HN: How do you get better at debugging/finding a solution?
#45This talk, "Debugging with the Scientific Method" changed how I debug problems. I try to watch it once every year or two. tl;dr, when debugging people naturally form a hypothesis about what is going wrong and then set about gathering evidence to support or refute that hypothesis. When you do so unconciously you are very prone to biases of all sorts, most importantly confirmation bias. When you do so mindfully, and Wr…
Re: Ask HN: How do you get better at debugging/finding a solution?
#46Also, print statements or use a debugger to confirm assumptions. (I'll be honest, I rarely bring out a debugger unless a print based workflow is time consuming enough to justify remembering everything about the debugger).
Re: Ask HN: How do you get better at debugging/finding a solution?
#47Instead, I've found much more deliberate practice and therefore value from reverse engineering: just like in debugging, you want to understand the underlying logic through program analysis.
You can pick security CTFs, crackmes, malware samples, proprietary software with bugs you want to fix, or functionalities you want to add, or even games where you want to find some hidden content, extract some resources, or modify some behaviors. In all that you will find something of your interest, and apply approaches that I think translate well to software development:
* Differential tracing: Want to know how some action reflects in the codebase? Take k instruction traces where you do everything except that action, then take a trace where you do that action, find out what are the unique differences in that last trace. Want to know what data gets written? Same approach with memory dumps and breakpoints. How do different inputs affect these changes? You will learn to be methodic and throughout in what you test and log.
* Recognizing patterns: Sometimes you don't have symbols for your functions, are you able to identify printf at a glance, or will you waste time following the logic of the function? Do you see relative offsets being used and recognize accesses to an array? With source code all this happens on a more macro view, such as algorithms or design patterns hidden in all those coupled functions and classes. But the micro view also applies: figure out what constants relate to specific functionalities, and you can grep your way to relevant functions or documentation.
* Avoiding boilerplate: This follows from the previous point, since you want to recognize the flow of data through the codebase, in order to have some call hierarchy to follow, otherwise it's easy to waste time on functionally that is irrelevant to you. Start with how data enters the application: stdin, files, database connections, http endpoints... Tests, examples, or client apps will also help here.
Oh and don't worry about learning some assembly language, just make that investment, since that's the straightforward, well defined, predictable part.
Re: Ask HN: How do you get better at debugging/finding a solution?
#48Sometimes I allow myself to be annoyed that the code isn't working and that is the wrong mindset.
Everyone will experience problems but suffering is a choice.
Re: Ask HN: How do you get better at debugging/finding a solution?
#49The most important thing is understanding the problem itself. So in the case of compile issues, rust for me has just blown me away. But I won't harp on.
There are times too where it's just not clicking and you shouldn't be afraid to step away from it for a bit. I like taking a walk. But something to step away from it.
I do have crazy lows when I'm just stuck and feel so stupid at that moment. But solving it then gives that addictive high.
As for tools and those obscure errors that are impossible I'm always reminding myself of the X Y problem and to make sure I'm not getting trapped in it!
Power through though, you're not alone and all the problema you've solved you'll remember!
Re: Ask HN: How do you get better at debugging/finding a solution?
#50It's hard to debug a problem if you have no idea what most of the code is supposed to do. You can go for speed - asking colleagues that do know - or you can just start following the code until you understand it. That will take more time of course, but in time you will start having enough knowledge of the code base that you can just start throwing guesses when there's a problem.
My 2 cents in case i read your question right. If i haven't, there are a few answers describing debugging techniques :)