<?xml version="1.0" encoding="windows-1252"?>
<node id="152803" title="Re: Plural variable naming (or not?)" created="2002-03-19 13:15:32" updated="2005-07-21 01:31:06">
<type id="11">
note</type>
<author id="76537">
andreychek</author>
<data>
<field name="doctext">
I have really come to enjoy the ideas and syntax offered by the &lt;a href="http://www.officevision.com/pub/p5ee/software/htdocs/P5EEx/Blue/perlstyle.html"&gt;P5EE  Style Guide&lt;/a&gt;.&lt;br&gt;&lt;br&gt;

In the guide, they offer this for plural vs singular variable naming conventions:

&lt;code&gt;
---

Arrays and hashes should be plural nouns, whether as
regular arrays and hashes or array and hash references. Do
not name references with ``ref'' or the data type in the
name.

    @stories     = (1, 2, 3);      # right
    $comment_ref = [4, 5, 6];      # wrong
    $comments    = [4, 5, 6];      # right
    $comment     = $comments-&gt;[0]; # right

---
&lt;/code&gt;

By consistantly using a system like this throughout your programs, there won't have to be question about whether a scalar contains something like a string, or if it's a reference to an array or hash.  As the guide suggests, references would be named in a plural fashion.&lt;br&gt;&lt;br&gt;

FWIW, I'm now using (or at least attempting to) this guide for all of my programming habits :-)  Have fun,&lt;br&gt;
 -Eric
 </field>
<field name="root_node">
152710</field>
<field name="parent_node">
152710</field>
</data>
</node>
