Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Class::DBI misbehaviour

by liz (Monsignor)
on Mar 11, 2004 at 12:52 UTC ( [id://335789]=note: print w/replies, xml ) Need Help??


in reply to Class::DBI misbehaviour

FWIW, I would write this code:
$shift->caption($args->{'caption'}); $shift->starts($args->{'starts'}); $shift->ends($args->{'ends'}); $shift->monday($args->{'monday'}); $shift->tuesday($args->{'tuesday'}); $shift->wednesday($args->{'wednesday'}); $shift->thursday($args->{'thursday'}); $shift->friday($args->{'friday'}); $shift->saturday($args->{'saturday'}); $shift->sunday($args->{'sunday'}); $shift->holiday($args->{'holiday'});
as:
$shift->$_( $args->{$_} ) foreach qw( caption starts ends monday tuesday wednesday thursday friday saturday sunday holiday );
You're specifying things twice (name of method and name of field in hash), which is always bad from a maintenance point of view.

Also, I find the use of $shift confusing: usually a variable called $self is a more common idiom.

Liz

Replies are listed 'Best First'.
Re: Re: Class::DBI misbehaviour
by TVSET (Chaplain) on Mar 11, 2004 at 13:02 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-09-08 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.