Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Access to single object from multiple other objects

by Anonymous Monk
on Nov 01, 2013 at 03:55 UTC ( #1060702=note: print w/replies, xml ) Need Help??

in reply to Re: Access to single object from multiple other objects
in thread Access to single object from multiple other objects

Looks like passing it to the objects as an argument is the preffered solution. My only issue with that is that I have a relatively large object hierarchy, with something similar to the following objects:

A instantiates B and C B instantiates D D instantiates E [...]
So now if E needs access to the config module I'll have to pass it all the way down.

Yes, passing is slightly more typing, but if you don't, then you're accessing a global variable -- which is worse? The following might shed a little light

Why Singletons are Evil - Being Scott Densmore - Site Home - MSDN Blogs , Use your singletons wisely ; Know when to use singletons, and when to leave them behind

So a global app configuration is common use of a singleton ... I've used it, I've seen it used ... I don't really have an informed opinion :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060702]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2018-06-20 02:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.