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
Category: 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
TDD, GoogleTest, GitHub, Travis CI and Conan; the easy way!
Test-Driven Development (TDD) is a popular approach in developing code bases and there is a good reason for that. There are many books that explain the way and the advantages of adopting an approach like that. In today’s post, I’m not going to explain that again. An amazing book that I can suggest is the
Continue reading TDD, GoogleTest, GitHub, Travis CI and Conan; the easy way!
How to install Armadillo library, the easy way!
Back to May, we have written a post about the procedure we need to follow in case we want to use the Armadillo library in Ubuntu. It works, but in this post, I would suggest an even easier way to do it. The solution called Conan, the C/C++ Package Manager. It can be used for
Continue reading How to install Armadillo library, the easy way!
One more naming convention for C++
Lot of discussion about what should be the proper naming convention for C++. Bjarne Stroustrup has recommended the following approach, which is useful as advice: Name a variable (function, type, whatever) based on what it is or does. Choose a meaningful name; that is, choose names that will help people understand your program. Even you
How to use pimpl idiom to hide the internals of your class declaration (and not only)
When we share the public interface of our library or API, we usually share the header files. In this case together, with the public members od our class there is also visibility of the private. The pimpl idiom which comes from the “pointer to implementation” is a programming technique that let us hide the internal