"Delaney, Timothy" <tdelaney at avaya.com> wrote in message news:mailman.988071155.16112.python-list at python.org... [snip] > > Over the last week or so, the singleton DP came up for discussion > > a couple of times on this group -- I seem to be in a tiny minority > > in disliking it intensely in favour of featherweight proxies, though ... > Just to add my support to Alex here - we haven't always agreed on everything > (c.f. ''.join() ;) but I'm in complete agreement in this case. Flyweight is Ok, not QUITE so tiny:-). > a *very* useful design pattern, whilst *public* Singleton is incredibly > difficult to enforce. You are best to have a private Singleton (i.e. it is > only visible to your code) and expose its interface via a Flyweight. ...and then there is no need for the Singleton Design Pattern -- just instance the 'whatever' only once, it IS your code so that ain't hard:-). > Simplest way to do this would be to have a non-static class only declared > and implemented and instantiated in the implementation (.cpp) file where > your Flyweight class is implemented. I think (been a while since I've done > any C++ work). Yep, that would work. Or you may 'risklessly' expose it by putting it as a private nested class inside your public flyweight class, with its sole instance as a private static member for the flyweight class (I think your idea works better though). Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4