[Cs3] CS3 singleton question

Mikhail Nesterenko mikhail at cs.kent.edu
Wed Mar 21 14:55:47 EDT 2018


> 
> I have been writing some practice code and I ran into this website:
> https://sourcemaking.com/design_patterns/to_kill_a_singleton
> 
> It has some interesting singleton ideas. It specifically recommends
> singleton implicit destruction using a friend class. Just wondering if you
> think this is a good solution to singleton destruction.
> 

Multiple inter-dependent singletons is a thorny issue since the order
of their destruction is unclear.  More on that in Andrei
Alexandresku's "Modern C++ Design". Singleton implementation gets even
more complicated in a multithreaded environment. Here is an
interesting article:

  http://jrruethe.github.io/blog/2015/08/02/singletons/

The programming community is split on singletons. A number of experts
advise against using it altogether. I am just providing a warning.

However, I think this material is too involved for CS3. 

Thanks,
-- 
Mikhail


More information about the cs3 mailing list