in reply to For Review: OOP DB Import

One slightly tangential note: using a module like Class::Accessor automates the accessor/mutator method creation for you, and makes it simple to add new ones as well:

package My::Object; use strict; use base qw( Class::Accessor ); my @FIELDS = qw( dsn username password table ); My::Object->mk_accessors( @FIELDS ); ...

To add a new accessor/mutator, we just need to stick a new field into @FIELDS.

Chris
M-x auto-bs-mode

Replies are listed 'Best First'.
Re: Re: For Review: OOP DB Import
by impossiblerobot (Deacon) on Feb 05, 2002 at 15:46 UTC
    Thanks, lachoy. I've seen several pieces of code (including a couple of examples here at the Monastery) for auto-generating accessors using closures (which is apparently what Class::Accessor does). But I had never seen this module before; I think it might be useful.

    I didn't auto-generate the accessors in this first draft because I wasn't sure of the design -- specifically what accessors I should use and how they should work. But that was stupid, because I could have shortened the code somewhat and made it just as easy to modify later.

    (One of the purposes for this exercise was to use the language I know -- and love -- best to master concepts from languages I don't know. Do other languages have the ability to auto-generate accessors?)

    Impossible Robot