Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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 :)


Comment on Re^2: Access to single object from multiple other objects
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2014-08-22 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (164 votes), past polls