Design Patterns

C++ Observer Pattern

What is Observer Pattern? Observer pattern is a behavioral design pattern. Observer pattern is used to solve the problem of notifying multiple objects of a change to keep them in sync like the Model-View-Controller (MVC) concept. Useful for event management kind of scenarios. Two classes are involved. The Observable class is where the actual data …

C++ Observer Pattern Read More »

C++ Factory Pattern

Factory Pattern Factory pattern is a creational design pattern. Idea of the factory patterns is to localize the object creation code. This prevents disturbing the entire system for a new type introduction. Typically when a new type is introduced in the system, change is at one place only where the object is created to decide …

C++ Factory Pattern Read More »

C++ Singleton

Singleton Singleton is a creational design pattern. A design pattern to provide one and only instance of an object. Make the constructors of the class private. Store the object created privately. Provide access to get the instance through a public method. Can be extended to create a pool of objects. Sample Program #include <iostream>using namespace std;// …

C++ Singleton Read More »