4.82 out of 5
4.82
19 reviews on Udemy

Creational Design Patterns in Modern C++

Learn creational design patterns in depth & their implementation in Modern C++
Instructor:
Umar Lone
216 students enrolled
English [Auto]
Understand what creational design patterns are
How creational design patterns solve object construction problems
Implement singleton correctly in C++ with thread-safety
Use factory method to encapsulate the construction process
Use object pool pattern to avoid repetitive construction & destruction of objects
Control construction process of an object through builder
Clone expensive objects through prototype
Use abstract factory to construct objects based on a context

Design Patterns are a way to solve common object oriented design problems. But understanding and learning design patterns is hard and takes time. Looking at a pattern is like looking at a solution without a problem, unless you’ve encountered the problem in the past.

This course aims to help you understand & implement Creational Design Patterns. Each pattern is explained with multiple examples and through modern C++. This helps you understand how the pattern can be implemented efficiently using language features. The examples do not involve cars, pizzas, ducks, coffee, etc. These topics are rarely used while building real-world software. Instead I provide real-world  examples written in Modern C++. These examples will compile & execute on any platform that supports a C++ compiler.

This is how the course teaches creational patterns.

  1. The intent, structure of the pattern is explained through UML class diagram.

  2. Basic implementation details of the pattern are explained.

  3. The pattern is implemented in a simple example.

  4. You get familiar with the overall implementation of the pattern.

  5. Another example is introduced that has design issues the pattern aims to resolve.

  6. We examine the issues and refactor the code by applying the design pattern step by step.

  7. Alternative scenarios & examples are explained along with differences between them. You also learn how to decide between different alternatives.

  8. I discuss the pattern in context of C++ and how to tweak it for performance, reusability & maximum flexibility.

  9. Finally, you’ll learn when to use the pattern and its pros & cons.

This is an intensive discussion that spans multiple lectures. At the end of each section, you’ll understand the pattern in depth and can apply it in your code or easily clear any design interview.

Introduction

1
Course Introduction

Instructor & course introduction.

2
Introduction to Patterns

Understand what "pattern" means.

3
Overview of UML Class Diagram

Quick introduction to UML class diagrams.

4
S.O.L.I.D. Principles - I

Understand what SOLID principles are. This video explains single responsibility & open closed principle.

5
S.O.L.I.D. Principles - II

This lecture explains the Liskov Substitution Principle

6
S.O.L.I.D. Principles - III

This lecture explains the interface segregation & depending inversion principle.

7
Creational Patterns Overview

Gives a quick overview of creational patterns.

8
Course Material (Slide Deck)

Slide deck.

Singleton

1
Code

Demo project of Singleton pattern

2
Introduction

Explains the intent of this pattern & its basic implementation.

3
Basic Example

Shows a simple implementation of the pattern.

4
Logger Class - I

Demonstrates the issues in a class and why it needs to be a singleton.

5
Logger Class - II

The Logger is refactored to a singleton. Additionally, it is made non-copyable.

6
Lazy Instantiation

The example is modified for lazy instantiation.

7
Destruction Policies

Learn about the issues with lazy instantiation & how to resolve them.

8
Multithreading Issues

Demonstrates the problem of using singleton in a multithreaded application.

9
Why DCLP Fails

Learn how double-checked locking pattern can fail in some scenarios.

10
Meyer's Singleton

Demonstrates how to implement Meyer's singleton.

11
Using std::call_once

Demonstrates the usage of call_once function.

12
CRTP Idiom

This lecture demonstrates how to use CRTP idiom to implement a singleton class through inheritance.

13
Clock Class

An example that does not require a singleton implementation for singularity.

14
Monostate Pattern

Learn what monostate pattern is and how to implement it.

15
Singleton Vs Monostate

This lecture compares singleton & monostate that will help you decide which one to use.

16
Singleton Issues

Learn about the several issues with incorrect implementation of the Singleton Pattern.

17
Registry Of Singletons - I

Learn how to implement registry of singletons.

18
Registry Of Singletons - II

This lecture demonstrates how to implement the registry using lazy instantiation.

19
Pros & Cons

In this lecture, I discuss pros & cons of the singleton design pattern.

Factory Method

1
Code

Demo project of Factory Method pattern

2
Introduction

Introduction of the factory method, its intent & structure.

3
Basic Implementation - I

This video shows a simple example without the factory method design pattern.

4
Basic Implementation - II

In this lecture, I implement the factory method in the previous example.

5
Application Framework Discussion

I explain the example of a framework in which we'll later implement the factory method.

6
Application Framework Implementation

The application framework is implemented without the pattern. This helps us understand the issues with the design.

7
Application Framework with Factory Method

In this lecture, you'll learn how to implement the factory method in the application framework.

8
Parameterised Factory Method

Demonstrates an alternative implementation of the factory method.

9
std::unique_ptr

This example shows several examples of how & why a factory method can be implemented as a global function.

10
std::shared_ptr

Continues the discussion of factory methods as functions.

11
Pros & Cons

Understand the pros & cons of the factory method and when to apply it.

Object Pool

1
Source Code
2
Introduction

Learn the intent, structure and implementation details of the object pool pattern.

3
Basic Example

This video demonstrates a simple example of the pattern.

4
Pooling Game Objects - I

The lecture starts with an example of a game that can benefit from pooling large number of game objects.

5
Pooling Game Objects - II

In this lecture, I demonstrate how to use pooling for Missile class objects.

6
Multiple Actors - I

I update the example to support multiple types of Actors.

7
Multiple Actors - II

This lecture shows the implementation of Acquire & Release methods.

8
Multiple Actors - III

This videos shows how to reduce dependency on concrete classes through a factory.

9
Generic Pool - I

Learn how to create a generic object pool that can work with any class.

10
Generic Pool - II

This video improves the implementation with custom allocator.

11
Pros & Cons

Understand the pros and cons of the object pool pattern and when to use it.

Abstract Factory

1
Code

Demo project of  Abstract Factory

2
Introduction

Introduction to the pattern, its intent & structure.

3
Basic Example

This lecture demonstrate a simple example that will be implemented later with Abstract Factory.

4
Basic Implementation with Abstract Factory

The example in the previous example is modified and refactored to use the Abstract Factory.

5
Database Framework Introduction

This lecture explains the example that will be used for explained the Abstract Factory pattern.

6
Database Framework Implementation

Continue understanding the implementation of the database framework.

7
SqlServer Database Classes

We add the Sql database classes & understand their usage.

8
MySql Database Classes

In this lecture, I'll add the MySql database classes.

9
Database Framework Usage

We'll use the database framework classes from the client through macros & conditional statements.

10
Using Factory Method

Macros & conditional statements are inflexible for creating instances of database classes. In this lecture, we'll attempt to use the factory method design pattern.

11
Using Abstract Factory

The db framework is refactored to use the Abstract Factory design pattern.

12
Pros & Cons

Understand the pros & cons of this pattern.

Prototype

1
Code

Demo project of the Prototype pattern

2
Introduction

Introduction to the pattern and its intent.

3
Cloning Types

Understand the basics of cloning and how to use the prototype pattern to implement it.

4
Basic Example

Implementation of the prototype pattern with a basic example.

5
Game Introduction

Introduction to the example used for prototype design pattern.

6
Game implementation - I

In this part, I'll add the Animation & the Vehicle class.

7
Game implementation - II

This lecture continues with implementation of the Vehicle subclasses.

8
Game implementation - III

This lecture adds the GameManager that creates the instances of the Vehicle subclasses.

9
Cloning Example

Understand why cloning is useful.

10
Prototype Implementation - I

In this lecture, I implement the prototype pattern through shallow copy.

11
Prototype Implementation - II

Continuation of the previous lecture. You'll also see the issues with shallow cloning.

12
Prototype Implementation - III

We refactor the game to use deep copy to prevent issues with shallow copy.

13
Class Vs Object

Understand how we can use different instances of the same class with variations in states. This reduces the number of classes in the game.

14
Varying State

In this lecture, we'll remove extra car & bus classes. Instead, by varying the state of few objects, we'll simulate objects of other classes.

15
Prototype Manager - I

In this lecture, we implement the prototype manager.

16
Prototype Manager - II

In this part, we complete the implementation of prototype manager.

17
Memory Management

We'll modify our implementation to use smart pointers to avoid manual memory management.

18
Pros & Cons

Understand the pros & cons of this pattern and when to use it.

Builder

1
Code
2
Introduction

Introduction of the pattern, along with its intent & structure.

3
Basic Implementation

Basic implementation of the builder pattern.

4
File Example Introduction

Introduction to the File example.

5
Issues

This lecture explains the design issues with the File example.

6
Builder Implementation

In this lecture, we refactor the code to use the builder pattern.

7
Construction Using Builder

Usage of the File class through the builder pattern.

8
Modern Implementation

This lecture demonstrates how to implement a modern builder without creating too many classes.

9
Fluent Builder

This lecture shows an alternative implementation of the builder that uses a fluent interface.

10
Pros & Cons

Understand the pros & cons of the builder pattern and when to use it.

11
BONUS LECTURE
You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.8
4.8 out of 5
19 Ratings

Detailed Rating

Stars 5
15
Stars 4
3
Stars 3
1
Stars 2
0
Stars 1
0
8cd3556bb31a89a630a34dcb469d9446
30-Day Money-Back Guarantee

Includes

8 hours on-demand video
8 articles
Full lifetime access
Access on mobile and TV
Certificate of Completion