this post was submitted on 10 Apr 2025
20 points (100.0% liked)
No Stupid Questions (Developer Edition)
1014 readers
1 users here now
This is a place where you can ask any programming / topic related to the instance questions you want!
For a more general version of this concept check out [email protected]
Icon base by Lorc under CC BY 3.0 with modifications to add a gradient
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It's never OK in my experience.
If its debug logs, call the logger instead of print, like Log.debug() or something. If its part of a test, it shouldn't be in the code itself. And it's not a feature either as you said. Neither logs nor test or feature: remove it.
It may also bite you in the ass one day if the output is stored or tested or filtered and someone wonders who added that unspecified stuff. We never print anything raw like that at my job, and if I saw this I would wonder who is printing random crap and I would remove that because its "useless for the application."
I think “never OK” is overly proscriptive — we use the term best practice because there are less preferable solutions that are nonetheless viable — but your advice to use a proper logger is sound. Many developers don’t think to use them and they offer many benefits in terms of maintainability.
Its not a best practice IMHO. Its never OK because of the 3 alternatives that exist, and because its forbidden in some regulated jobs.
Certainly not best practice. The reason I referred to the term is that “best” implies a spectrum of acceptability, where the “never OK” end of the spectrum includes stuff like storing user credentials in plaintext.
But also, if anything but best practice was truly never OK, there are many smaller programs that wouldn’t see the light of day, and there definitely wouldn’t be any junior developers.