3 ms·
Store them in static private variables of a singleton object. An example http://pastebin.com/Gf4fzHn2 http://pastebin.com/Gf4fzHn2 This way you could lookup t
by DjDarkman 16y ago
Store them in static private variables of a singleton object.
An example
http://pastebin.com/Gf4fzHn2 http://pastebin.com/Gf4fzHn2
This way you could lookup the parts of the code that use your global stuff, because they have to get it though the static method call.
- chime 16y agoThis is exactly what my argument was against. Why make it complex when a simple global would do? Why say GlobalSingleton::var when global $unique_var would do, as long as the app does not abuse these global vars?
- DjDarkman 16y agoIt's a few lines of code, I would not call that complex. And the usage is. GlobslSingleton::set('Something Meaningful',$unique_var); and GlobslSingleton::get('Something Meaningful'); I don't think this is complex at all. This doesn't force you to use $unique_var as a variable name(I know it can be worked around). One of the biggest problem with globals is that they can crash and burn if someone else's code purges it by accident. Also my pattern allows 'load on demand', I can incorporate it in if I'd want to, your does not.