Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I will agree, variable naming is very important, but it really depends upon scope. If i am writing a one-liner, i'll use the fewest characters possible, such as $f, @f, or %f. If i am writing a throw away script, i don't feel quilty for using foo, bar, baz, and qux here and there. If it is a script that i plan for others to use, i sit and think very carefully about the names. If i am working with a group, i will do my best to stick to whatever standards they have agreed upon.

Coming from Java, i used to name my variables like employeeRecord and thingWithNoName, but now i stick to the convention of using all lower case and separating words with the underscore - thing_with_no_name. This also keeps me from chosing long names since i hate reaching for the underscore key. ;)

When confronted with mental block on finding a good name, if i can't think of one in 5 minutes or less, i will pick something and move on. Leaving a comment that promises to rename the variable reminds me of why i did so. I really feel that names are important, but not so important as to get stuck in rut over them. This is similar to listening to someone's conversation when they pause for far too long trying to find the right word, completely losing their train of thought.

Final comment - plurals. tye finally convinced me to avoid using plurals for arrays and hashes, because they already indicate a colletion: @file, @line, %record. This keeps me from guessing between $file and @file, $record and %record. This is also a new practice for me, so i sometimes forget.

jeffa

Consistency is golden

In reply to (jeffa) Re: Of variable {mice} and its name {man}. by jeffa
in thread Of variable {mice} and its name {man}. by vladb

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 admiring the Monastery: (5)
As of 2024-03-28 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found