I introduced this a while back because we had dozens of places where
we were using globals to accomplish this in a variety of uniquely
buggy ways. Then we had equally subtle code that might reach in and
play w/ the global. Like:
https://codereview.chromium.org/436963003/diff/1/tools/telemetry/telemetry/core/backends/chrome/android_browser_finder_unittest.py
I'm not tied to it at all, but would like to point at that if we stop
using it, we're going to have to re-implement some form of that global
variable hack in lots of places. If each is a little different, it is
going to be even harder to grok.
What if, instead, we changed the global one to be called @Singleton or
something and make the decorator enforce a naming convention on the
creator. For instance CreateSingletonFoo() -- Where the
"CreateSingleton" is enforced. It could also have some kind of Reset()
helper.
If folks agree on this or a similar pattern, I'd be happy to do a
cleanup sweep to convert everything.
Thoughts?
-Tony