[cgiapp] code reuse.

Mark Fuller azfuller at gmail.com
Sun Mar 16 19:59:12 EDT 2008


On Sun, Mar 16, 2008 at 4:31 PM, James.Q.L <shijialeee at yahoo.com> wrote:
>
>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.

The example your provided showed them being passed as parameters to
$self->methods() which have access to the param method..

If you're passing them to true subroutines (not methods) there's no
way around that except to begin refactoring your code into objects.
That's the problem I had a few years ago and found myself bundling
things into one hash which could be passed around (a lot like an
object). Or, creating modules to hold the data belonging to that
namespace within that namespace (a lot like an object). And then,
voila!, a module with a hash (an object).

>  i like to define $uuid,

I might be missing the point, but what's wrong with storing $uuid in
Company::Util as an "our" variable and accessing it from anywhere as
$Company::Util::uuid ?

I'm not sure that's the right thing to do. But, it's what you're
asking for. If you're going through what I did, once you do that I bet
you proceed to an object. Or, making your subroutines methods.

Maybe you should post a different example? It sounds like the one you
posted didn't represent the problem you're having?

Mark


More information about the cgiapp mailing list