Isaac
Lifelong Learner
- Local time
- Yesterday, 20:29
- Joined
- Mar 14, 2017
- Messages
- 8,777
Although we all embrace the necessity of the Q&A method to resolving problems on our forum, it's an excellent practice to allow ourselves to be challenged in how to troubleshoot problems on our own. This article (and a few others like it) should be a sticky on AWF! It separates the mediocre from the excellent, although of course most of us dip our toes into both categories depending on the day!
This challenged me quite a bit - and also made me drool over the tools that other platforms have, like Debug.Assert
Anyway, enjoy!
This is my favorite quote if I had to pick one:
This challenged me quite a bit - and also made me drool over the tools that other platforms have, like Debug.Assert
Anyway, enjoy!
How to debug small programs
(Este artigo está disponível em português.) One of the most frequent categories of bad questions I see on StackOverflow is: I wrote this program for my assignment and it doesn’t work. [20 lin…
ericlippert.com
This is my favorite quote if I had to pick one:
If your program still has a bug, obtain a rubber duck. Or if a rubber duck is unavailable, get another computer science undergraduate, it’s much the same. Explain to the duck using simple words why each line of each method in your program is obviously correct. At some point you will be unable to do so, either because you don’t understand the method you wrote, or because it’s wrong, or both. Concentrate your efforts on that method; that’s probably where the bug is. Seriously, rubber duck debugging works. And as legendary programmer Raymond Chen points out in a comment below, if you can’t explain to the duck why you’re executing a particular statement, maybe that’s because you started programming before you had a plan of attack.
Once your program compiles cleanly and the duck doesn’t raise any major objections, if there’s still a bug then see if you can break your code up into smaller methods, each of which does exactly one logical operation. A common error amongst all programmers, not just beginners, is to make methods that try to do multiple things and do them poorly. Smaller methods are easier to understand and therefore easier for both you and the duck to see the bugs