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

Re: Re: Shift versus Sanity

by drewbie (Chaplain)
on Apr 24, 2002 at 14:14 UTC ( #161612=note: print w/replies, xml ) Need Help??


in reply to Re: Shift versus Sanity
in thread Shift versus Sanity

# Bad sub bar { my $self = shift; my %options = @_; }
I have to disagree with you on this one, sort of. I use this construct to set defaults to named parameters like this:
sub bar { my $self = shift; my %options = (opt1=>'foo', # desc for opt1 opt2=>'bar', # desc for opt2 @_); }
To me, this is the best of both worlds. I get an obvious object ($self), I know what my expected named arguments are, their default values, and a brief description of each parameter. Yes, it's slightly more memory intensive, but it's so much more intuitive to me that I'll take the tradeoff anyday.

As someone else said, I'll take maintainability over a little verboseness & overhead anyday. Being able to figure out what the heck a rarely used option does is invaluable 4 months (or years!) down the road.

Replies are listed 'Best First'.
Re: Re: Re: Shift versus Sanity
by Juerd (Abbot) on Apr 24, 2002 at 17:34 UTC

    I use this construct to set defaults to named parameters like this

    Oops, forgot about that idiom. Yes, when using to set defaults, it is okay :)

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2020-11-27 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?