in reply to need help developing fly OO style

Another option is to pass the handle to your module's constructor, and have it stored as an element of the blessed hash (assuming you use a hash, that is). The drawback to this is that you'll have to create an instance of your class for each different database handle you need, though btrott's example has a similar weakness. (And it's not really a weakness.)

Replies are listed 'Best First'.
RE: pass to modules constructor solution
by markjugg (Curate) on Aug 12, 2000 at 12:32 UTC
    This solution has it's merits as well. However for a small script that uses just one database handle but only 1 call to the module (let's say CGI::SQL), then I get a call like this: my $obj = new CGI::SQL($DBH); my $result = $obj->insert_sql_from_param; So, I end up writing two lines and making two calls where I might just make one with another solution. However, if I made lots of calls to CGI::SQL in my script, this overhead would be low and worthwhile. I'll consider working with this solution. Thanks!