Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

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

Now you've circled back around to scope size again. If your sub is around one screenful of code, it's easy to know what each var is and does, because you can at a glance see it in use without paging or having to search an entire file.

Then, you have your documentation (you did write documentation, right? ;)

Often when I'm writing new modules or updating older ones, I have the current documentation open in either a browser or another terminal window. Your documentation will provide you with the function/method declaration, and will clearly describe what each parameter is. I'm not advocating using comments here, I'm just saying in rare cases where it may be ambiguous to the reader, throw in a comment. fwiw, I don't recall over the last year ever having to specify what a variable is via comment in any of my code.

In your example, with those names, I immediately and instinctively knew which type each param was. If I was to update that sub, the worst thing that would happen would be an error spit out because I mistakenly used the variable as a different type, and since I test code extremely often, there wouldn't be much I'd have to go back and change to correct my oversight.


In reply to Re^5: Improve readability of Perl code. Naming reference variables. by stevieb
in thread Improve readability of Perl code. Naming reference variables. by hakonhagland

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 goofing around in the Monastery: (3)
As of 2024-04-24 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found