-
The Observer Pattern
One of the fundamental software behavioral patterns discussed in the Gang of Four’s Design Patterns, the observer pattern is very useful for maintaining one-to-many relationships between objects. As such, it is typically implemented in OOP languages such as C++, Java, Rust, etc. This article will explore the motivation behind using the observer pattern, and an…
-
The Curiously Recurring Template Pattern
The Curiously Recurring Template Pattern (CRTP) is a C++ design pattern that exhibits some interesting behavior related to inheritance and polymorphism. It is considered an idiomatic design pattern, meaning it incorporates semantic design principles for efficiently implementing a recurring construct. In this instance, CRTP is heavily tied to C++ given the language features that C++…
-
The pImpl Pattern
Certain class implementations carry with them a lot of compile-time dependencies, and making changes to those will require recompilation of everything that uses a representation of the class. The pImpl (pointer to Implementation) pattern alleviates compile-time dependencies by moving all the implementation-level details of a class into a different class that is accessible via an…
-
The Singleton Pattern in C++
A singleton is a class that does not allow for dynamic instantiation. At runtime, one instance of the class is statically initialized, and this instance cannot be copied or assigned. To use the object, an accessor method is provided within the class definition to allow another portion of the program to grab a reference. Here…