Factory pattern is another prevalent pattern that we need to know. The main principle about the factory is that it separates the creation from use. But what does this means? We design a factory entity that creates the objects we want depending on what we want. We do not use the constructors directly on the
Tag: modern c++
SOLID Principles in modern C++
When talking about patterns, one acronym seems to be the most popular, the SOLID principles. Yes, actually SOLID is an acronym that stands for: Single Responsibility, Open-closed, Liskov substitution, Interface Segregation and Dependency Inversion Too many strange terms, a little bit dry. I can think of two things that will help us go through. The
Observer Pattern in modern C++
We have started a series of posts trying to present ridiculous popular design patterns using examples in modern C++. Again, the inspiration came from the great youtube video series, ArjanCodes. This time we are going to talk about the observer pattern which is going to help us separate various modules in our code. The key
GitHub Actions and Conan
It’s always wise to use continuous integration (CI), even in our hobby projects. When working with C++, it might be painful to install the required dependencies, even for the most essential packages like the googletest for the unit tests or the spdlog for the logger. In those cases, using Conan package manager is a no
Dependency Inversion Pattern in modern C++
Dependency inversion is one more pattern that is going to help us improve abstraction. We mean that by applying this approach, we separate the definition of an interface from the actual implementation. To explain the pattern, there is a classic example with the light bulb and the switch. If we assume that we want to
Strategy Pattern in modern C++
In this post, I’m going to talk about the strategy pattern. As I have mentioned in a previous post, my initial inspiration started as I watched ArjanCodes youtube video tutorials. In of those (link), he began to explain the strategy pattern. This approach comes in handy when we build a structure, and we could have
The Template Method Pattern and the Bridge Design Pattern in modern C++
Is developing software only good (or excellent) knowledge of a programming language? Of course not. There are many things, but one of the most important is to know patterns. It might be not obvious when you develop elementary apps at the beginning of your journey, but it becomes necessary when developing decent packages for professional
Continue reading The Template Method Pattern and the Bridge Design Pattern in modern C++
How to achieve Rule of Zero
We have all heard about the the rule of Five and rule of Zero when it comes to C++ programming. The latter says to avoid implementing any special function as much as possible. When we talk about special member functions, we refer to: Copy constructor Copy assignment operator Move constructor Move assignment operator Destructor Hmm,
Sets in C++17 and a custom comparator
Sets belong to the associative containers family. This category facilitates very fast element search. Sets contain keys that are always ordered and unique. The class template for sets is like that: std::set<T, Comparator, Allocator> where T is the key type, Comparator is the algorithm with which we perform the ordering and defaults to std::less and