Re:Debug Programs by Modifying Them
by mousepilot on Wednesday April 28, 2021 @12:24PM
(#26971168)
honestly, when I approach programming, a primary concern is to spend effort to help make the program easier to modify. I'm not the original proponent of that as a goal, its just something I read somewhere but it really helped me in my career.
It makes total sense to insert a lot of logging statements into your code, which can be switched on when you need to diagnose something. This can be also used then in production, where you can't just change code (but switch the log level in the config). Very useful
Adding and removing print statements (== modifying code) as you are investigating is bad practice, because you are modifying the program you try to fix. It can be a lot of clutter inside the code, and maybe you fix/break the program by coincidence and didn't even notice. Once you undo your changes, before committing the bug is back.