Liskov's Substitution Principle in C++ | SOLID as a Rock

So you know how to code in general, understand the object-oriented programming, learned C++, and completed at least one Software Development Course (if you’re not there yet, these articles aren’t for you). You can write software easily if you know at least one programming language, but is your code any good? Could it be done any better? Is it clean (and what on earth does that mean)? Is your architecture any good?...

April 7, 2020 · 7 min · 1387 words · Vishal Chovatiya

Open Closed Principle in C++ | SOLID as a Rock

This is the second part of a five-part article series about SOLID as Rock design principle. The SOLID design principles, when combined together, make it easy for a programmer to craft software that is easy to maintain, reuse & extend. Open-Closed Principle(OCP) is the second principle in this series which I will discuss here with minimalistic example in Modern C++ along with its benefits & generic guideline. By the way, If you haven’t gone through my previous articles on design principles, then below is the quick links:...

April 7, 2020 · 8 min · 1596 words · Vishal Chovatiya

Single Responsibility Principle in C++ | SOLID as a Rock

This article is the first part of a five-part series about SOLID as Rock design principle series. The SOLID design principles focus on developing software that is easy to maintainable, reusable & extendable. In this article, we will see an example of the Single Responsibility Principle in C++ along with its benefits & generic guideline. By the way, If you want to directly jumps to other design principles, then below is the quick links:...

April 7, 2020 · 6 min · 1105 words · Vishal Chovatiya

What Is Design Pattern?

After hitting a certain level of experience & spending quite enough time in the industry, I have realised the importance of designing/architecting system & software. So I have started looking into system/software design & got to know nothing can better start than a Design Pattern. And the first thing I have done is googling “What is Design Pattern?” Hence got the idea of this article. But as someone without a computer science background(I am from electronics background), learning them was a struggle....

April 7, 2020 · 8 min · 1576 words · Vishal Chovatiya

Builder Design Pattern in Modern C++

In software engineering, Creational Design Patterns deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic or ordinary form of object creation could result in design problems or added complexity to the design. Builder Design Pattern in C++ solves this specific problem by separating the construction of a complex object from its representation. By the way, If you haven’t check out my other articles on Creational Design Patterns, then here is the list:...

April 6, 2020 · 9 min · 1802 words · Vishal Chovatiya

Dependency Inversion Principle in C++ | SOLID as a Rock

Dependency Inversion Principle in C++ is the fifth & last design principle of a series SOLID as a Rock design principles. The SOLID design principles focus on developing software that is easy to maintainable, reusable & extendable. In this article, we will see an example code with the flaw & correct it with help of DIP. We will also see guideline & benefits of DIP in closure of the article....

April 6, 2020 · 6 min · 1203 words · Vishal Chovatiya

Factory Design Pattern in Modern C++

In software engineering, Creational Design Patterns deal with object creation mechanisms, i.e. try to create objects in a manner suitable to the situation. In addition to this basic or ordinary form of object creation could result in design problems or added complexity to the design. Factory Design Pattern in C++ helps to mitigate this issue by creating objects using separate methods or polymorphic classes. By the way, If you haven’t check out my other articles on Creational Design Patterns, then here is the list:...

April 6, 2020 · 10 min · 2040 words · Vishal Chovatiya

Interface Segregation Principle in C++ | SOLID as a Rock

Interface Segregation Principle in C++ is the fourth & by far the simplest design principle of a series SOLID as a Rock design principles. The SOLID design principles focus on developing software that is easy to maintainable, reusable & extendable. In this article, we will see a code violating ISP, a solution to the same code, guideline & benefits of ISP. By the way, If you haven’t gone through my previous articles on design principles, then below is the quick links:...

April 6, 2020 · 5 min · 1014 words · Vishal Chovatiya

Prototype Design Pattern in Modern C++

Prototype Design Pattern is a Creational Design Pattern that helps in the prototyping(creating/copying cheaply) of an object using separate methods or polymorphic classes. You can consider the prototype as a template of an object before the actual object is constructed. In this article of the Creational Design Patterns, we’re going to take a look at why we need a Prototype Design Pattern in C++ i.e. motivation, prototype factory & leveraging prototype design pattern to implement virtual copy constructor....

April 6, 2020 · 9 min · 1805 words · Vishal Chovatiya

Singleton Design Pattern in Modern C++

In software engineering, Creational Design Patterns deal with object creation mechanisms, i.e. try to create objects in a manner suitable to the situation. The basic or ordinary form of object creation could result in design problems or added complexity to the design. In this article of the Creational Design Patterns, we’re going to take a look at the much-hated & commonly asked design pattern in a programming interview. That is Singleton Design Pattern in Modern C++ which criticizes for its extensibility & testability....

April 6, 2020 · 9 min · 1810 words · Vishal Chovatiya

Adapter Design Pattern in Modern C++

In software engineering, Structural Design Patterns deal with the relationship between object & classes i.e. how object & classes interact or build a relationship in a manner suitable to the situation. The structural design patterns simplify the structure by identifying relationships. In this article of the Structural Design Patterns, we’re going to take a look at Adapter Design Pattern in Modern C++ which used to convert the interface of an existing class into another interface that client/API-user expect....

April 5, 2020 · 7 min · 1317 words · Vishal Chovatiya

Bridge Design Pattern in Modern C++

Bridge Design Pattern is a Structural Design Pattern used to decouple a class into two parts – abstraction and it’s implementation – so that both can be developed independently. This promotes the loose coupling between class abstraction & its implementation. You get this decoupling by adding one more level of indirection i.e. an interface which acts as a bridge between your original class & functionality. Insulation is another name of Bridge Design Pattern in C++ world....

April 5, 2020 · 8 min · 1646 words · Vishal Chovatiya

Composite Design Pattern in Modern C++

GoF describes the Composite Design Pattern as “Compose objects into a tree structure to represent part-whole hierarchies. Composite lets the client treat individual objects and compositions of objects uniformly”. This seems over-complicated to me. So, I would not go into tree-leaf kind of jargon. Rather I directly saw you 2 or 3 different ways to implement Composite Design Pattern in Modern C++. But in simple words, the Composite Design Pattern is a Structural Design Pattern with a goal to treat the group of objects in the same manner as a single object....

April 5, 2020 · 8 min · 1683 words · Vishal Chovatiya

Decorator Design Pattern in Modern C++

In software engineering, Structural Design Patterns deal with the relationship between object & classes i.e. how object & classes interact or build a relationship in a manner suitable to the situation. The Structural Design Patterns simplify the structure by identifying relationships. In this article of the Structural Design Patterns, we’re going to take a look at the not so complex yet subtle design pattern that is Decorator Design Pattern in Modern C++ due to its extensibility & testability....

April 5, 2020 · 8 min · 1611 words · Vishal Chovatiya

Facade Design Pattern in Modern C++

Facade Design Pattern is a Structural Design Pattern used to provide a unified interface to a complex system. It is same as Facade in building architecture, a Facade is an object that serves as a front-facing interface masking a more complex underlying system. A Facade Design Pattern in C++ can: Improve the readability & usability of a software library by masking interaction with more complex components by providing a single simplified API....

April 5, 2020 · 5 min · 920 words · Vishal Chovatiya

Flyweight Design Pattern in Modern C++

Flyweight Design Pattern is a Structural Design Pattern that concerned with space optimization. It is a technique to minimizes memory footprint by sharing or avoiding redundancy as much as possible with other similar objects. Flyweight Design Pattern in Modern C++ is often used in a situation where object count is higher which uses an unacceptable amount of memory. Often some parts of these objects can be shared & kept in common data structures that can be used by multiple objects....

April 5, 2020 · 6 min · 1098 words · Vishal Chovatiya

Proxy Design Pattern in Modern C++

In software engineering, Structural Design Patterns deal with the relationship between objects i.e. how objects/classes interact or build a relationship in a manner suitable to the situation. The Structural Design Patterns simplify the structure by identifying relationships. In this article of the Structural Design Patterns, we’re going to take a look at Proxy Design Pattern in C++ which dictates the way you access the object. If you haven’t check out other Structural Design Patterns, then here is the list:...

April 5, 2020 · 7 min · 1378 words · Vishal Chovatiya

Chain of Responsibility Design Pattern in Modern C++

Chain of Responsibility is a Behavioural Design Pattern that provides facility to propagate event/request/command/query to the chain of loosely coupled objects. Chain of Responsibility Design Pattern in Modern C++ lets you pass requests along a chain of handlers & upon receiving a request, each handler decides either to process the request or to forward it to the next handler in the chain. By the way, If you haven’t check out my other articles on Behavioural Design Patterns, then here is the list:...

April 3, 2020 · 7 min · 1337 words · Vishal Chovatiya

Command Design Pattern in Modern C++

In software engineering, Behavioural Design Patterns deal with the assignment of responsibilities between objects which in turn make the interaction between the objects easy & loosely coupled. In this article of the Behavioural Design Patterns, we’re going to take a look at Command Design Pattern in Modern C++ which encapsulate all the details related to operation into a separate object. Command Design Pattern is widely used in sophisticated software. In fact, you might be using it every day without even knowing that....

April 3, 2020 · 7 min · 1415 words · Vishal Chovatiya

Interpreter Design Pattern in Modern C++

Interpreter Design Pattern is a Behavioural Design Pattern which is a component that processes structured text data by turning it into separate lexical tokens(lexing) and then interpreting sequences of tokens(parsing). In this article, we will see the Interpreter Design Pattern in Modern C++. By the way, If you haven’t check out my other articles on Behavioural Design Patterns, then here is the list: Chain of responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor The code snippets you see throughout this series of articles are simplified not sophisticated....

April 3, 2020 · 6 min · 1254 words · Vishal Chovatiya

Iterator Design Pattern in Modern C++

Iterator Design Pattern in Modern C++ is a heavily used pattern i.e. provides facility to traverse data containers sophistically. For simplicity, you can consider a pointer moving across an array, but the real magic comes when you get to the next element of a container, in that case, you need not know anything about how the container is constructed(like sequential(not necessarily be contiguous), associative or hashed). This is handled by the iterator....

April 3, 2020 · 10 min · 1918 words · Vishal Chovatiya

Mediator Design Pattern in Modern C++

In software engineering, Behavioural Design Patterns deal with the assignment of responsibilities between objects & encapsulating behaviour in an object to delegate requests. In this article of the Behavioural Design Patterns, we’re going to take a look at Mediator Design Pattern in Modern C++. And the motivation behind the Mediator Design Pattern is to provide proper communication between components by letting the components be aware(or unaware also, depending upon use case) of each other’s presence or absence in the system....

April 3, 2020 · 6 min · 1071 words · Vishal Chovatiya

Memento Design Pattern in Modern C++

Memento Design Pattern in Modern C++ is a very straight forward Behavioural Design Pattern. The motivation behind using the Memento Design Pattern is to keep some sort of token which then allows you to restore an object to a particular state. This is particularly useful if you have a system with medieval components i.e. an object or indeed a set of objects goes through a set of changes. By the way, If you haven’t check out my other articles on Behavioural Design Patterns, then here is the list:...

April 3, 2020 · 5 min · 1039 words · Vishal Chovatiya

Observer Design Pattern in Modern C++

The Observer Design Pattern is a type of Behavioural Design Pattern that use to get information when certain events happen i.e. basically one component want information about something happening in the other component. And that can a lot of things like a field changes to a particular value or you want to information when the object does a particular thing, etc. Observer Design Pattern in Modern C++ enables you to create subscription mechanism to notify multiple objects about events that happen to the object they’re observing....

April 3, 2020 · 5 min · 1026 words · Vishal Chovatiya

Double Dispatch : Visitor Design Pattern in Modern C++

In software engineering, Behavioural Design Patterns deal with the assignment of responsibilities between objects. That in turn, make the interaction between the objects easy & loosely coupled. In this article of the design pattern series, we’re going to take a look at Visitor Design Pattern in Modern C++ which is also known as a classic technique for recovering lost type information(using Double Dispatch[TODO]). Visitor Design Pattern is used to perform an operation on a group of similar kind of objects or hierarchy....

April 2, 2020 · 10 min · 2108 words · Vishal Chovatiya

State Design Pattern in Modern C++

A State Design Pattern is a type of Behavioural Design Pattern that defines objects behaviour(defined as a state) based on some event happens. And that can be the internal or external event. For example, if you design an ATM machine using the State Design Pattern, the external event could be someone inserted debit/credit card & internal event could be a user timeout. So in nutshell, the State Design Pattern in Modern C++ is a systematic way to implement certain behaviour on a particular event considering the context....

April 2, 2020 · 11 min · 2304 words · Vishal Chovatiya

Strategy Design Pattern in Modern C++

In software engineering, Behavioural Design Patterns deal with the assignment of responsibilities between objects which in turn make the interaction between the objects easy & loosely coupled. In this article of the Behavioural Design Pattern series, we’re going to take a look at Strategy Design Pattern in Modern C++. It allows you to partially specify the behaviour of the class and then augment it later on. This pattern is also known as policy in many programming languages including especially in the C++ language....

April 2, 2020 · 6 min · 1179 words · Vishal Chovatiya

Template Method Design Pattern in Modern C++

In software engineering, Behavioural Design Patterns deal with the assignment of responsibilities between objects. And encapsulating behaviour in an object to delegate requests. The Behavioural Design Patterns make the interaction between the objects easy & loosely coupled. In this article of the design pattern series, we’re going to take a look at Template Method Design Pattern in Modern C++. It allows us to define the skeleton of the algorithm in the base class with concrete implementations defined in derived classes....

April 2, 2020 · 6 min · 1097 words · Vishal Chovatiya