3 ms·
FWIW, if you really want to understand Pattern Language you should go and read the source material: Christopher Alexander's book of the same name and it's compa
by carapace 5y ago
FWIW, if you really want to understand Pattern Language you should go and read the source material: Christopher Alexander's book of the same name and it's companion volumes. The GoF did a fine job, but there's a richer and deeper constellation of ideas and philosophy and design strategies in the original material.
- - - -
In re: Singleton pattern in Python: one interesting technique is to use a module as a singleton. When client modules "import singlefoo" the first import caches the module object (in the sys.modules dict) and subsequent imports use it: presto! Singleton!
- codr7 5y agoMy first thought was that it's nice to see someone take such a humane and scientific approach to public spaces, and a lot of it makes sense. But to me that's the real essence of the book, not the fact that it contains patterns. It should be required reading for city planners, not software developers.
- sateesh 5y agoYeah, this is usually the best way for creating singleton in Python. But this makes mocking the singleton module in unit tests harder, as this line is run during module import itself. If the singleton is making a network connection (say) and you want to mock it for the unit tests, things get clumsy and harder.
- bmn__ 5y ago> there's a richer and deeper constellation of ideas and philosophy and design strategies in the original material Explanation with a bit more details: https://perl.plover.com/yak/design/ https://perl.plover.com/yak/design/