Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Constructive criticism of a dictionary / text comparison script

by Hutta (Scribe)
on Aug 29, 2003 at 23:41 UTC ( [id://287858]=note: print w/replies, xml ) Need Help??


in reply to Constructive criticism of a dictionary / text comparison script

I normally wouldn't be this picky, but you were asking for comments on coding style, so I'd have this to offer:
GetOptions( 'help|?' => \$help, 'version' => \$version, 'man' => \$man, 'token-debug' => \$token_debug, 'glossary' => \$glossary_output, 'dictionary' => \$dictionary_output );
This tends to be an easier-to-read way to format hash-like structures. I also tend to put all of my commandline options into a single hash (%opt, or %arg, or something) when they're going to be global. This saves variable namespace, but may be a petty concern.

Replies are listed 'Best First'.
Re: Re: Constructive criticism of a dictionary / text comparison script
by allolex (Curate) on Aug 30, 2003 at 05:52 UTC

    Yes, that looks is a lot easier to read than the separate option declarations. Actually, I thought I reformatted that before I posted it here... Go figure :) I also like the idea of declaring the option init values in a hash, since it would make the code more legible (not to mention namespace economy). I'll definitely make both of those changes.

    --
    Allolex

Re: Re: Constructive criticism of a dictionary / text comparison script
by exussum0 (Vicar) on Aug 30, 2003 at 20:11 UTC
    Well, you bring up a good point. Problem with passing hashes to say, something like functions, is when you misslpell variables/keys, you wind up with a maintenance issue. so when you write a function like,

    add(-number1=>10,-nuber2=>0),

    you get a right result, but not the right way. Granted, this is the easist bug to bring out, try adding 5 and 3 to get 0. But when you do it with more complex scenarios, you can get really weird software bugs. Also, it makes it harder to refactor code, when you wish to remove parameters, add them or make different requirements, 'cuz when they get called, they may not break.. unless you check for every old parameter and new one in your functions. Yuck. Just a rant :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found