How to write a Singleton (3/5)

In two previous posts I have tried to convince you not to implement the Singleton at all and to give up implementing it with lazy initialisation. Today I show how to write a singleton that uses lazy initialization. The presented code is one of 3 possible versions – the most readable one. Others will be [...]

How to write a Singleton? (2/5)

In one of the recent posts I was trying to convince everyone not to create singletons. For those who still are not convinced I show today how to write it in a simplest and safest way possible. The following code base on one assumption: you do not need lazy initialization.
The idea behind lazy [...]