Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Of strict, globals, packages and style

by jdporter (Paladin)
on Oct 20, 2005 at 19:00 UTC ( [id://501782]=note: print w/replies, xml ) Need Help??


in reply to Of strict, globals, packages and style

I think it's an excellent idea. What you've hit upon is called the Strategy design pattern. I like this pattern and I use it a lot. The fact that you invented it independently just proves that it's a real pattern. :-)

The outline you illustrated is a framework. The dbi handle, ftp handle, etc. exist as Singletons within that framework. When you call the strategized methods, they're being called in the context of the framework, so you should probably pass a handle to that context to the called method. Using that handle, the method can get at the singleton objects that live in the framework. When you've achieved this, you won't need any real global data at all. (The "global" data can easily be limited to lexicals in the main program file.)

We're building the house of the future together.
  • Comment on Re: Of strict, globals, packages and style

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found