Kategorie: design patterns

Design Patterns in C++: Strategy

The Strategy Pattern allows you to change an algorithm at runtime. Image for example some algorithms to calculate the square root, as you may know there are plenty of it. They all do the same, but they all have their own upsides and downsides – one is more accurate, the other one is less expensive…
Weiterlesen

Design Patterns in C++: Observer

The Observer Pattern is one of the heavily used ones and well, the name says it : It’s purpose is to observe other classes for any updates. To be a bit more exact: you register the Observer classes at the Subject class and when the Subject changes, then all Observers get notified. So, to be…
Weiterlesen

Design Patterns in C++: Singleton

The Singleton Design Pattern guarantees that there is always at most one lonesome instance of the class around. The following implementation of a Singleton in CPP is thread-safe as long as you are using C++11 or above! It is based on a stackoverflow Q&A. Singleton_Classname.h Singleton_Classname.cpp