4 ms·
> using 'printf'-style debugging And the horror that descends upon you once you commit+push those statements.
by abhishekjha 8y ago
> using 'printf'-style debugging
And the horror that descends upon you once you commit+push those statements.
- pjc50 8y agoEither "don't do that then" or have a logging framework that lets you leave enough printf in to diagnose crashes in the field.
- abhishekjha 8y agoI used to debug using print statements earlier and that was because we were not allowed to use any IDE. Now that I know hoe to use IDEs properly, things have been better. And there is always logging and `git diff` to help you out. Those colouring schemes really come handy.
- Vinnl 8y agoA pre-commit hook can prevent that for you. (I use a linter that will only allow log statements if they're preceded by an exception comment, which I will only add if I actually intend to log things.)
- JustSomeNobody 8y agowhat I do in the situation where I have had to track down a really elusive bug and chased it around the code with print statements is checkout a fresh copy of the code and only merge in my fix.
- taneq 8y agoDo you people not read through your changes before checking in? I mean, it's better to buddy check-ins but even rubber-ducking through the changes will catch a ton of mistakes.
- coldtea 8y agoWhat horror? At best it might be a slight embarrassment (that can be avoided by checking the diff before commit). Then again, having killed the bug is more important than pretty commits.
- jpindar 8y agoDoesn't happen to me. My printfs start like this: if (debugLevel != 0) printf(.... Sometimes the condition compares debugLevel to some other value, but it will never print if debugLevel is zero, and its going to be zero unless I set it to something else.