Or maybe “singleton is the new _root.”
Ha. Just something someone threw out there jokingly in Toronto at FiTC. Keeps coming back and making me laugh whenever I think of making anything a singleton.
Of course, a singleton can be used for good or for evil. [Insert something about great power and responsibility here…]
Funny how we can always find out new, complicated, highly elegant techniques to write the same old crappy code.
Yeah, it’s been a long day.
Keith,
I have laughed about that one since FITC. I recall Darron and Aral were trying to explain the merits of using Singleton to me. Somehow “Singleton is the new _global” made sense at the time.
Ted 😉
Ah, it was you. I knew it was one of you guys, just couldn’t remember which one. 🙂
😉
It’s really sad that late at night this is what we find amusing…. Not making any judgments here, just pointing it out
This singleton walks into a bar…
… and became “obfusticated”. 😉
Hahaha. I remember that one too!
heh…thats funny becaue jsut yesterday i threw a “_root” into my code (i know, i’m a bad person…) and was thinking i “really” should” work it into a singleton…
anyway, at least a singleton would be more portable than _root, right?
It was mostly meant at humor, but it could probably bear a serious discussion. The evils of _root or _global are that if you use them in OO design, it can break encapsulation, because you can have your class functionality based on this external value that can be changed anywhere by anything.
That said, you could fall into the same trap with a singleton. If your class is relying on some data from a singleton, where your class functionality is based on this external thing that could be altered externally.
If you are using _root or _global in a class, there’s a good chance that there might already some poor design choices being made. If that’s the case, just shifting it over to a singleton is somewhat better, but doesn’t handle the basic problem.
Note my heavy use of subjunctive verbs here: could, can, might be, etc.