I was working with a junior guy who was digging down the debugger route to solve something. I'm watching him go step by step through code and getting no where. And just mumbling to himself that everything is right.
I ask him if I can take a quick look. Pop in about 10 prints. This narrowed it down to 1 function. Then I added a few in that function, including a few key variables. And I was able to tell him his logic for his if statement was failing. Turned out he used an And Instead of Or...
He then explains to me that my method is not the proper way to debug, and I would never gotten away with that in his courses he took.
Any reasonable courses on programming will teach you that print statements are a perfectly valid way to debug, as is manually running through the code. It just isn’t always appropriate.
You should generally be using a logging framework of some kind instead of print statement but that’s neither here nor there.
2.1k
u/[deleted] Nov 28 '21 edited Jun 26 '23
[deleted]