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

In reply to Re^2: Balancing Logging and Code Readability by ack
in thread Balancing Logging and Code Readability by ack

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.