Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Birthday List

by TomDLux (Vicar)
on Aug 28, 2003 at 18:05 UTC ( [id://287475]=note: print w/replies, xml ) Need Help??


in reply to Birthday List

Consider using Shell::POSIX::Select for the menus. For the price of a slight complication in code, you obtain robustness and greater user control.

Documenting variable declarations sounds good, and at one time was presented as an important software engineering technique. But look at your documentation:

my ($choice); # The user's choice. my ($name); # Person's name my ($date); # Birthday my (@birthdays); # List of Birthdays. my ($key);

Does "The user's choice" convey any more information than does "$choice"? or "Person's name" compared to "$name"? The one comment which clarifies the variable name is "$date" ... "Birthday", which leads me to suggest the variable name should be changed to "$Birthday". If you have comments, they should be more informative. As well, any information in comments appears once, at the declaration; any information in the variable name appears every time it is used.

Part of the reason C/Pascal/Ada programmers started using comments at the declaration is because declarations appeared at the top of the routine, far from the use. Variables $name and $date are only used at lines 33, 34, 35 and lines 54, 55, 56; @birthdays is only used lines 40-60. Declaring @birthdays at line 40, declaring $name and $date at line 33 and at line 54 means the names are totally sufficient documentation. As well, local declarations guarantee you don't have to worry about the variables being used elsewhere, simplifying comprehension.

My web site has an article on Coding Style, with links to stuff by Kernighan, Pike, chromatic, Mark-Jason, and many others. It makes interesting reading!

--
TTTATCGGTCGTTATATAGATGTTTGCA

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://287475]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found