Bifalgorithm post

Printing vs. Logging Which one should you be using and when? Well, it's all about intent. Printing makes sense when the intent is to show information to a user. Logging makes more sense when you want to record data for developers themselves. This can be things like timing, errors, or other debugging information. For example, let's say you write a program that retrieves and then shows a temperature. It should probably print the temperature since that's what users want to see when they run the program. But later on, suppose that users tell you that it's very slow once in a while. Then you as a developer might want to add logging statements to track the program runtime and debug the slowness. In most programming languages, these logging statements have the benefit that they can write to a completely separate file or output stream. That means you can collect data without disrupting the output that users see. If you found this helpful then follow for more.

Printing vs. Logging Which one should you be using and when? Well, it's all about intent. Printing makes sense when the intent is to show information to a user…

Ideas in this flowchart

  • Printing vs. Logging
  • Intent
  • Printing
  • Show information to user
  • Logging
  • Record data for developers
  • Timing, errors, debugging
  • Example: Temperature Program
  • Print temperature for users
  • Log runtime to debug slowness
  • Separate file/output stream
  • Collect data without disrupting user output
Feed/

Printing vs. Logging Which one should you be using and when? Well, it's all about intent. Printing makes sense when the intent is to show information to a user. Logging makes more sense when you want to record data for developers themselves. This can be things like timing, errors, or other debugging information. For example, let's say you write a program that retrieves and then shows a temperature. It should probably print the temperature since that's what users want to see when they run the program. But later on, suppose that users tell you that it's very slow once in a while. Then you as a developer might want to add logging statements to track the program runtime and debug the slowness. In most programming languages, these logging statements have the benefit that they can write to a completely separate file or output stream. That means you can collect data without disrupting the output that users see. If you found this helpful then follow for more.

"Printing vs. Logging Which one should you be using and when?"

👍
0
0 comments0 shares

Sign in to view and post comments.