3 ms·
Print debugging is okay, if you don't remove the print statements when you are finished. This technique is called logging or tracing, and is nothing new. It ma
by andix 6y ago
Print debugging is okay, if you don't remove the print statements when you are finished. This technique is called logging or tracing, and is nothing new.
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.
- mousepilot 6y agohonestly, 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.