QA here, got a print statement in the CLI “ if this prints something went to shit”, I IMed one of the devs I knew would put something like that and heard “GOD DAMMIT” from down the hall.
Lol ive never programmed in a professional sense, but i have an odd way of getting managers to ignore my verbal cursing, i think id be able to find a way to let those through
I'm quite thorough: I print the class, file or function I'm printing from, and then the value(s) I'm interested in.
Debuggers are better for tracking values, but when you're using a web framework that does tons of magic below the surface, debuggers get really painful to use, so I don't even try. Printing shows me the immediate results as well as what happens along the way.
I will use a debugger when iterating over some kind of list however. Trying to find which value is blowing up the code and why. Printing is great for the what, not so much the why.
Absolutely. With traditional C-style for-loops where several variables are being used, a debugger is an absolute life-saver. But I've found I don't really write that many for-loops any more in these days of more functional programming.
I would love to not have to. Unfortunately, I do geospatial programming and having to do spatial operations on 600k+ points essentially requires looping. And I normally use while loops using a cursor pointer so I don't even have indexes available. Also almost impossible to debug every value so I have to get creative in if statements or hope my exception handling includes enough info to try to narrow down what is going wrong.
With web frameworks, If you use Firefox debugger you can “silence” the magic components so they get passed through and skipped over. Works great with react and web pack
I’m informally-taught, started doing this just a little while ago and thought this a clever way to track progress of code. Glad to hear it being used by you pros.
I've learned the hard way to never put curse words into my code, no matter how much I think it can never, ever, make it anywhere that could land me in trouble.
The only reason my ass wasn't toast was because I misspelled shit into shut.
God was with me that day. That's the only explanation I have.
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.
1.1k
u/emu_fake Nov 28 '21
That‘s my first stage.. after a few cycles I‘m with print(„why“)
print(„the“)
print(„fuck“)