C++ Observer Implementation

The Observer design pattern is used for state change notifications. An object called subject (or publisher) has a list of dependents, called observers (or subscribers). When the subject changes state, all its dependents are notified by calling a method. The Observer pattern is useful for the implementation of event handling.

UML diagram


The observer interface has an abstract method used for notifications and the subject has methods for attachment and detachment of observers.
(more…)

C++ Singleton Implementation

Singleton is the simplest and probably the most widely used of all design patterns. It’s so popular that some IDEs (like SlickEdit) have templates for its generation. The purpose of this design pattern is to ensure that only one instance of a class is created.
So, why discuss Singleton?
(more…)