M
Mark Lawrence
Purely for fun I've been porting some code to Python and came across the
singletonMap[1]. I'm aware that there are loads of recipes on the web
for both singletons e.g.[2] and immutable dictionaries e.g.[3]. I was
wondering how to combine any of the recipes to produce the best
implementation, where to me best means cleanest and hence most
maintainable. I then managed to muddy the waters for myself by
recalling the Alex Martelli Borg pattern[4]. Possibly or even probably
the latter is irrelevant, but I'm still curious to know how you'd code
this beast.
First prize for the best solution is a night out with me, no guesses
what the second prize is
[1]http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html
[2]http://stackoverflow.com/questions/...le-elegant-way-to-define-singletons-in-python
[3]http://code.activestate.com/recipes/498072-implementing-an-immutable-dictionary/
[4]http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/
singletonMap[1]. I'm aware that there are loads of recipes on the web
for both singletons e.g.[2] and immutable dictionaries e.g.[3]. I was
wondering how to combine any of the recipes to produce the best
implementation, where to me best means cleanest and hence most
maintainable. I then managed to muddy the waters for myself by
recalling the Alex Martelli Borg pattern[4]. Possibly or even probably
the latter is irrelevant, but I'm still curious to know how you'd code
this beast.
First prize for the best solution is a night out with me, no guesses
what the second prize is
[1]http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html
[2]http://stackoverflow.com/questions/...le-elegant-way-to-define-singletons-in-python
[3]http://code.activestate.com/recipes/498072-implementing-an-immutable-dictionary/
[4]http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/