Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Balancing Logging and Code Readability

by ack (Deacon)
on Sep 17, 2009 at 02:06 UTC ( [id://795745]=note: print w/replies, xml ) Need Help??


in reply to Re: Balancing Logging and Code Readability
in thread Balancing Logging and Code Readability

Wow! Excellent suggestions and some interesting strategies that I hadn't ever thought of.

One thing I would suggest is that info and debug level logging can replace comments. Just like code, there is no sense duplicating non-code either.

That is something that had never occured to me. I really like that. It will take some getting used to, however. I tend do copious commenting and have found that, to some extent, the commenting (as with the logging) can easily get in the way of viewing the actual code logic and flows. The idea of using logging as an alternative to commenting sounds really powerful and offers the opportunity to "kill two birds with one stone" as they say.

As for the warn and error levels, testing for those cases could mostly be done at the beginning of a function, while you're gathering and validating parameters.

Again, a great suggestion. I will work on that.

Rather than putting a log message in the center of a function where it makes a call, try to move the logging into the function being called. The function was probably written to keep things clear and avoid duplication of code, so you might as well use it to avoid duplication of logging commands too.

So true and an excellent observation and strategy.

The trick would be learning to read debug-info logging as if it were a comment. Perhaps by adding a rule to the code highlighting in your editor.

I agree; it is something I'll have to work on.

One thing that your suggestions leave me curious about is sort of highlighted by that last comment (re: "...learning to read debug-info as if it were a comment..."). Does that bode poorly for maintainability of code by others? That is, does that tend to make the code less accessible to others who may not have developed the facility of reading debug-info as comments?

Just curious. Thanks so much for the great ideas and suggestions. I really appreciate it.

ack Albuquerque, NM
  • Comment on Re^2: Balancing Logging and Code Readability

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://795745]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found