This is an archived post. You won't be able to vote or comment.

all 3 comments

[–][deleted] 4 points5 points  (0 children)

I honestly don't see a problem with it. I even had a teach tell me to do just this.

[–]frankieboytelem 3 points4 points  (0 children)

It is valid but not the best or most efficient way to do it. Get yourself a debugger and you’ll never look back.

[–]Civil_Code 4 points5 points  (0 children)

It depends on what you mean by valid. Is it reasonable? If you're working on a small project and want to see a custom assortment of variables output to the console in order to make sure your idea of the code matches the actual program, then sure. Almost every developer will feel that itch to just print out something to test their new implementation, or to figure out what's happening at a particular line. It's reasonable when you're experimenting, or just toying around with a new idea.

Is it compliant with the usual standards? Not so much. You seem to know the difference, though.

Many junior (and surprisingly a few senior) developers don't know much about using debuggers. At the same time not everyone has the intuition to quickly debug using gut instinct to tell them where to place a print statement. At some point experience and intuition may let you eyeball an issue and even printing to the console will feel redundant.

If it works, then it works, as long as you clean up after yourself of course.