NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Language as a guide towards intuition (Score:1)
Nice writeup, and well put.
Another point that I would have made is: often, novices structure code in weird ways, with procedures that aren’t very useful outside the context in which they were conceived because they are big and do too many things. They use variables that get recycled over too many intermediate calculations, or conversely fail to break calculations into intermediate steps saved in variables.
Naming is a good detector for such problems. If you can’t think of a good precise name
naming arrays after their members (Score:1)
@persons means I start saying $persons[0], $persons[2]. @person reads nicer when referring to the elements, $person[1], $person[2].
But the second might confuse a reader of the code?
Re:naming arrays after their members (Score:1)
For arrays and hashes, I always use the singular form. The plurality is already implied by the sigil – putting it in the name as well would be repetition. Note also that there are many cases where you use the collection as a whole, which read nicer with a singular name, such as
push @person, $last_record(OK, I suppose that can be argued either way) orkeys %person_name.Reply to This
Parent