C++ Singleton design pattern

In 2008 I provided a C++98 implementation of the Singleton design pattern that is lazy-evaluated, guaranteed-destruction, not-technically-thread-safe:Can any one provide me a sample of Singleton in c++? Here is an updated C++11 implementation of the Singleton design pattern that is lazy-evaluated, correctly-destroyed, and thread-safe. See this article about when to use a singleton: (not often)Singleton: How … Read more

C++ Singleton design pattern

In 2008 I provided a C++98 implementation of the Singleton design pattern that is lazy-evaluated, guaranteed-destruction, not-technically-thread-safe:Can any one provide me a sample of Singleton in c++? Here is an updated C++11 implementation of the Singleton design pattern that is lazy-evaluated, correctly-destroyed, and thread-safe. See this article about when to use a singleton: (not often)Singleton: … Read more

What is a wrapper class?

In general, a wrapper class is any class which “wraps” or “encapsulates” the functionality of another class or component. These are useful by providing a level of abstraction from the implementation of the underlying class or component; for example, wrapper classes that wrap COM components can manage the process of invoking the COM component without … Read more

What is Inversion of Control?

The Inversion of Control (IoC) and Dependency Injection (DI) patterns are all about removing dependencies from your code. For example, say your application has a text editor component and you want to provide spell checking. Your standard code would look something like this: What we’ve done here creates a dependency between the TextEditor and the … Read more

What is dependency injection?

Dependency Injection is passing dependency to other objects or framework( dependency injector). Dependency injection makes testing easier. The injection can be done through constructor. SomeClass() has its constructor as following: Problem: If myObject involves complex tasks such as disk access or network access, it is hard to do unit test on SomeClass(). Programmers have to … Read more