Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

People have already written that one should comment, but i would like to make an addendum to that:
Comment well.

Bad comments are worse than no comments at all. Some areas need heavy commenting because they do the black magic of the program. In these cases, it's usually better to type up a well-written paragrah (in full english) that explains why the section does what it does and how. Then post that paragraph above the black magic and make sure it's noticeable and easy to read (using various commenting styles to make it obviously important)

As a general rule of thumb, if you can't comment it well you might reconsider how you're approaching the problem that the code solves. i've had to reinvent a code section three or four times on one program just because i couldn't describe why i did it that way that made any sense.

And lastly, to make sure that beautiful paragrah makes sense, see if a co-worker or pedestrian (hopefully with no knowledge of that section fo the program) can read and understand what you're trying to do. If they can, then when you go back and read it 2 days later, you should also have no problems.

This is just my experience, YMMV, HTH,
jynx

PS If it takes more than a paragraph to describe some code, maybe you're doing too much with that section, it might needs be split up, maybe...


In reply to Re: How to write long programms? by jynx
in thread How to write long programms? by pokemonk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found