[cgiapp] code reuse.
shijialeee at yahoo.com
Sun Mar 16 19:31:21 EDT 2008
--- Mark Fuller <azfuller at gmail.com> wrote:
> 1. You're storing $dbh and $uuid as a param in C::A. Why are you
> passing them as parameters instead of retrieving them from param?
I store ONLY $uuid in param because i need it in other controller. i am passing $dbh to Company::
modules because these modules are not inherited from C::A.
> 2. $uuid needs to be specific to this instance. But, $dbh might fit
> better in cgiapp_init, and stored as a class variable (of your
> package) so that, if you use some form persistence (mod_perl,
> fcgi/fastcgi, speedyCGI/persistentPerl/perperl) you'd only load and
> connect once. (But, you have to handle errors and reconnections due to
i am using DBI's connect_cached which supposed to return the same $dbh under persistent env.
> 3. Since you haven't made the step (yet) to make "Company::Util" an
> object, you could let it store $uuid in its own namespace (as an
> "our" variable?) and then access it directly wherever needed
> ($Company::Util::uuid). That's probably not the best practice. But,
> it's part of the evolution from subroutines to objects (which I think
> is the path you're on).
i like to define $uuid, $dbh in a central place and have it shared with Company::XX Company::YY
etc, regardless doing it in the object or class way. but i can't figure out how.
Never miss a thing. Make Yahoo your home page.
More information about the cgiapp