We may earn an affiliate commission when you visit our partners.
Course image
Dmitri Nesteruk

Course Overview

This course provides a comprehensive overview of Design Patterns in Modern C++ from a practical perspective. This course in particular covers patterns with the use of:

  • The latest versions of the C++ programming language
  • Use of modern programming approaches: dependency injection, use of coroutines, and more.
  • Use of modern developer tools such as CLion and ReSharper C++
  • Discussions of pattern variations and alternative approaches
Read more

Course Overview

This course provides a comprehensive overview of Design Patterns in Modern C++ from a practical perspective. This course in particular covers patterns with the use of:

  • The latest versions of the C++ programming language
  • Use of modern programming approaches: dependency injection, use of coroutines, and more.
  • Use of modern developer tools such as CLion and ReSharper C++
  • Discussions of pattern variations and alternative approaches

This course provides an overview of all the Gang of Four (GoF) design patterns as outlined in their seminal book, together with modern-day variations, adjustments, discussions of intrinsic use of patterns in the language.

What are Design Patterns?

Design Patterns are reusable solutions to common programming problems. They were popularized with the 1994 book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, John Vlissides, Ralph Johnson and Richard Helm (who are commonly known as a Gang of Four, hence the GoF acronym).

The original book was written using C++ and Smalltalk as examples, but since then, design patterns have been adapted to every programming language imaginable: Swift, C#, Java, PHP and even programming languages that aren't strictly object-oriented, such as JavaScript.

The appeal of design patterns is immortal: we see them in libraries, some of them are intrinsic in programming languages, and you probably use them on a daily basis even if you don't realize they are there.

What Patterns Does This Course Cover?

This course covers all the GoF design patterns. In fact, here's the full list of what is covered:

  • SOLID Design Principles: Single Responsibility Principle, Open-Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion Principle
  • Creational Design Patterns: Builder, Factories (Factory Method and Abstract Factory), Prototype and Singleton
  • Structrural Design Patterns: Adapter, Bridge, Composite, Decorator, Façade, Flyweight and Proxy
  • Behavioral Design Patterns: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Null Object, Observer, State, Strategy, Template Method and Visitor

Who Is the Course For?

This course is for C++ developers who want to see not just textbook examples of design patterns, but also the different variations and tricks that can be applied to implement design patterns in a modern way.

Presentation Style

This course is presented as a (very large) series of live demonstrations being done in JetBrains CLion. Most demos are single-file, so you can download the file attached to the lesson and run it in CLion, XCode or another IDE of your choice (or just on the command line).

This course does not use UML class diagrams; all of demos are live coding.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Recognize and apply design patterns
  • Refactor existing designs to use design patterns
  • Reason about applicability and usability of design patterns
  • Learn how to use different aspects of modern c++

Syllabus

Introduction

A taste of things to come... and yes, this is a course on Design Patterns. Join in, it should be a lot of fun!

Read more
Learn about the SOLID design principles used in software engineering

What are SOLID principles, where do they come from and why do we care?

A look at the Single Responsibility Principle, which states that a class should only have one reason to change. Also tied to the concept of Separation of Concerns which is basically stating the same thing.

A discussion of the Open-Closed Principle, which states that classes should be open for extension, but closed for modification. In other words, you should extend functionality using interfaces and inheritance rather than jumping back into already-written/tested code and adding to it or changing it.

This lesson also demonstrates the Specification pattern.

The Liskov Substitution Principle states that subtypes should be substitutable for their base types.

The Interface Segregation Principle is simple: don't throw everything in the kitchen sink into an interface because then all its users will have to implement things they do not need. Instead, split the interface into several smaller ones.

Not to be confused with dependency injection, dependency inversion specifies that high-level modules should not depend on low-level ones; both should depend on abstractions. Confusing, huh?

A summary of the things we've learned in this section of the course.

Learn to use the Builder design pattern

A brief note about the three categories of design patterns: creational, structural and behavioral.

A discussion of the Builder pattern and what it's used for.

A look at why you'd want to have a builder in the first place.

We implement a simple builder for constructing trees of HTML elements.

We make the builder fluent by returning this from builder methods.

Not so much a Builder pattern, but a clever way of using uniform initializer syntax to create a DSL for easily defining HTML constructs in a familiar manner.

We look at a more complicated builder facade that exposes several sub-builders (builder facets) for building up parts of an object in a fluent manner.

Builder Coding Exercise

A summary of the things we've learned about the Builder pattern.

Learn to use the Factory Method and Abstract Factory design patterns

A discussion of the general concept of factories and the two design patterns: Factory Methods and Abstract Factory.

A scenario where having a factory interface actually makes sense.

Implementing a factory method, as an alternative to a constructor, is easy.

When you want all the factory methods in a separate class.

An external factory needs the created object's constructor to be public. But what if you want it to be private? There are two solutions here: you either make a friend class or, alternatively, stick a factory into the class whose instance it creates!

Sometimes, you want abstract factories with abstract objects; we support DIP but break OCP in the process.

Thanks to constructs such as std::function, we can express factories in a purely functional way.

Factory Coding Exercise

A summary of the things we've learned about factories.

Learn to implement the Prototype design pattern

A discussion of the Prototype factory (not to be confused with a rather good game of the same name) and what it's used for.

A sample scenario where the Prototype pattern is relevant.

We implement the Prototype design pattern by making copy constructors.

If you find using prototypes a lot, and you need many of them, why not put them into a separate class? Separation of concerns!

One common approach to the Prototype pattern is to serialize-deserialize data. But you need to support it explicitly in each type you use.

Prototype Coding Exercise

A summary of all the things we've learned about the Prototype pattern.

Learn to implement the much-maligned Singleton design pattern

Ahh, the much maligned Singleton... is it really that evil? Let's find out...

Let's put together a simple implementation of Singleton before we start to embellish it with additional traits.

So, what's wrong with the Singleton? Well, hard dependencies on singletons are hard to test.

In order to write a unit test that uses a singleton, we must abstract it away. This is typically done by extracting the singleton's interface and then taking that interface as a dependency (e.g., a constructor parameter). This way, you can supply a fake object instead, thereby getting a true unit test instead of an integration test.

The only socially acceptable way of using a singleton is when you inject it as a dependency. DI containers allow you to configure a singleton lifetime for a component.

The Monostate design pattern is a bizarre variation on the Singleton: it's a type that appears just as an ordinary type (meaning you can construct multiple instances), but all its fields are actually private and static and are exposed with non-static getters and setters. More of a scientific curiosity rather than a viable design solution, this one.

Yet another variation on the Singleton, a Multiton is nothing more than a key-value store with on-demand creation.

Singleton Coding Exercise

A summary of all the things we've learned about the Singleton design pattern.

Learn to implement the Adapter pattern

An overview of the Adapter design pattern.

Let's look at a visual demonstration for a change. This MFC application can only render points, but all we have are lines. We need an adapter!

It just so happens that an adapter generates lots of temporaries. Let's see if we can add some caching to reduce the workload.

Adapter Coding Exercise

A summary of all the things we've learned about the Adapter design pattern.

Learn to implement the Bridge pattern

A look at the Bridge design pattern...

Pimpl Idiom

You can simplify the Pimpl idiom with a reusable class.

Bridge Implementation
Bridge Coding Exercise

A summary of all the things we've learned about the Bridge design pattern.

Learn to implement the Composite design pattern

A discussion of what the Composite pattern is for and how it's used.

Let's implement the Composite pattern by considering individual geometric shapes as well as grouping of shapes.

Let's apply the Composite pattern to the implementation of simple neural networks (individual neurons and layers of neurons).

Having individual fields with getters and setters is all fine until you want to perform aggregate operations on all the available fields. This calls for an alternative approach, which is an unusual blend of the Composite and Proxy design patterns.

Composite Coding Exercise

A summary of all the things we've learned about the Composite design pattern.

Learn to implement the Decorator design pattern

An overview of the Decorator design pattern.

The simplest form of Decorator.

Sophisticated decorators which make use of mixin inheritance, constructor forwarding and concepts.

Decorators are typically applied to classes, but it is equally possible to build decorators which wrap arbitrary chunks of code.

Decorator Coding Exercise

A summary of all the things we've learned about the Decorator design pattern.

Learn to implement the Façade design pattern

An overview of the Facade design pattern.

Rather than implementing the Facade from scratch, let's implement it on an existing project!

A summary of the things we learned about the Facade design pattern.

Learn to implement the Flyweight design pattern

An overview of the Flyweight design pattern.

Let's see how we can implement a simple flyweight by hand.

A ready-made flyweight solution can be found in the Boost libraries. Here's a demo of how to use it, plus we verify that it actually works.

Another example of the Flyweight design pattern, this time applied to the concerns of a text editor.

Flyweight Coding Exercise

A summary of all the things we've learned about the Flyweight design pattern.

Learn to implement the Proxy design pattern

An overview of the Proxy design pattern.

One example of a Proxy that we all know and love is, of course, the smart pointer classes such as shared_ptr.

A property proxy is a class that can serve as a drop-in replacement for a field but act like a property (i.e., have special getters and setters).

A virtual proxy is a proxy object that lies to you. Basically, it pretends that there is a real, underlying object behind it, whereas in reality, that underlying object might not even exist! One use of a virtual proxy is for lazy loading.

A communication proxy hides away the means of communication. What looks like an in-process call might actually be an RPC or RESTful invocation!

Proxies and decorators look very similar, so what's the difference?

Proxy Coding Exercise

A summary of all the things we've learned about the Proxy design pattern.

Learn to implement the Chain of Responsibility design pattern

An overview of the Chain of Responsibility design pattern.

The simplest Chain of Responsibility is a singly-linked list of pointers. Nothing sophisticated here!

We look at an industry-strength implementation of Chain of Responsibility, which also covers the Mediator, Observer and Command design patterns.

Chain of Responsibility Coding Exercise

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Develops skills and knowledge that are useful for personal growth and development
Taught by Dmitri Nesteruk, who are recognized for their work in C++
Taught by instructors who are recognized for their work in C++
Examines Design Patterns, which is highly relevant to C++
Covers unique perspectives are ideas that may add color to other topics and subjects
Provides an overview of all the Gang of Four (GoF) design patterns as outlined in their seminal book

Save this course

Save Design Patterns in Modern C++ to your list so you can find it easily later:
Save

Reviews summary

Great learning resource for up-and-coming programmers

According to students, Design Patterns in Modern C++ is a valuable learning resource for any aspiring programmer. Learners say this course offers inspiring instruction, doesn't waste time and helps them learn by coding along. Students note it's important to code these designs rather than simply try to understand them. They also stress the importance of regularly redoing the examples to avoid forgetting the material. To get the most out of this course, students suggest trying to adapt the examples to personal projects as soon as possible.
Repeating examples helps improve memorization.
Coding as you learn helps retain the material.
"I code in the same time as I watch and redo later the most fundamental exercises. In this way, I really feel I learn a lot."
This course presents material in an inspiring and engaging way.
"Very useful for every would-be programmer, taught in an inspiring way, doesn't lose time."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Design Patterns in Modern C++ with these activities:
Review 'Head First Design Patterns'
Reviewing a classic design patterns textbook can help you better understand the concepts.
Show steps
  • Read the book's introduction and first chapter.
Join a study group for C++ design patterns
Joining a study group can help you learn from others and reinforce your understanding of design patterns.
Show steps
  • Find a study group that meets regularly to discuss C++ design patterns.
  • Attend the study group meetings and participate in the discussions.
Practice Factory pattern coding exercises
Coding exercises help solidify your understanding of design patterns.
Browse courses on Factory Method
Show steps
  • Solve the coding exercises at the end of each Factory pattern lesson.
Five other activities
Expand to see all activities and additional details
Show all eight activities
Follow tutorials on Singleton design patterns
Following tutorials can help you learn how to implement the Singleton design pattern in C++.
Browse courses on Singleton
Show steps
  • Search for tutorials on Singleton design patterns in C++.
  • Follow a few tutorials and try to implement the pattern in your own code.
Create a project that uses the Builder design pattern
Starting a project that uses the Builder design pattern can help you apply your knowledge and improve your skills.
Browse courses on Builder
Show steps
  • Think of a project idea that could benefit from using the Builder design pattern.
  • Design the classes and interfaces for your project.
  • Implement the Builder class and the classes it builds.
  • Test your project to make sure it works as expected.
Write a blog post about the Decorator design pattern
Writing a blog post can help you solidify your understanding of the Decorator design pattern and share your knowledge with others.
Show steps
  • Choose a specific aspect of the Decorator design pattern to focus on.
  • Write a draft of your blog post, explaining the concept and providing examples.
  • Edit and proofread your blog post.
  • Publish your blog post.
Participate in a coding competition that focuses on design patterns
Participating in a coding competition can help you test your skills and learn from others.
Show steps
  • Find a coding competition that focuses on design patterns.
  • Register for the competition and prepare for it.
  • Compete in the competition and try your best.
Contribute to an open-source project that uses design patterns
Contributing to an open-source project can help you learn from others and gain practical experience with design patterns.
Show steps
  • Find an open-source project that uses design patterns.
  • Read the project's documentation and code.
  • Make a contribution to the project, such as fixing a bug or adding a feature.

Career center

Learners who complete Design Patterns in Modern C++ will develop knowledge and skills that may be useful to these careers:
Software Engineer
The course is titled "Design Patterns in Modern C++". A Software Engineer uses these design patterns, which aid in creating reusable solutions to common programming challenges, as a core part of the job. The course goes into particular depth on how to use these design patterns with the latest version of C++.
Computer Programmer
In the course, you will learn all the Gang of Four (GoF) design patterns, together with modern-day variations and discussions of intrinsic use of patterns in the language.
Web Developer
A Web Developer's primary concern is using programming languages to build websites. Although web development focuses on the design and front-end implementation of websites, this course helps with the usability of web development design patterns across the stack.
Mobile Application Developer
This course can teach a Mobile Application Developer looking to work with C++ about the different variations and tricks that can be applied to implement design patterns in a modern way in order to create mobile applications.
Systems Analyst
A Systems Analyst designs and implements computer systems. This course may be useful for someone in this role who is looking to learn how to reason about the applicability and usability of design patterns.
Data Scientist
This course may be useful for Data Scientists seeking to learn about design patterns in modern C++ and who are specifically interested in using modern developer tools such as CLion and ReSharper C++.
Database Administrator
This course may be useful for a Database Administrator looking to learn about using design patterns such as Singleton, Builder, and Factory Method and Abstract Factory as there is a focus on patterns with the use of the latest versions of the C++ programming language.
IT Manager
This course may be useful for an IT Manager seeking to learn about design patterns with the use of modern programming approaches such as dependency injection and use of coroutines.
Information Security Analyst
The course covers topics such as the SOLID design principles: Single Responsibility Principle, Open-Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion Principle, which are useful concepts for an Information Security Analyst to understand.
Quality Assurance Analyst
This course may be useful for a Quality Assurance Analyst seeking to learn about design patterns as this knowledge can help with analyzing the quality of software.
Technical Writer
This course may be useful for a Technical Writer who wants to learn about design patterns, which are reusable solutions to common programming problems, and how to use different aspects of Modern C++.
UX Designer
This course discusses the use of modern developer tools such as CLion and ReSharper C++, which can help a UX Designer to gain a better understanding of the technical side of programming.
Product Manager
This course may be useful for a Product Manager who needs to learn how to recognize and apply design patterns, refactor existing designs to use design patterns, and reason about applicability and usability of design patterns.
Project Manager
This course may be useful for a Project Manager who wants to gain a better understanding of design patterns and how they can be used in modern C++.
Business Analyst
This course may be useful for a Business Analyst who wants to learn about different design patterns and how to use them to solve common programming problems.

Reading list

We've selected 13 books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Design Patterns in Modern C++.
Provides a comprehensive overview of design patterns in Modern C++ from a practical perspective. It covers all the GoF design patterns, as well as modern-day variations and adjustments, and discussions of intrinsic use of patterns in the language.
This is the original book on design patterns and is considered a classic in the field. It provides a comprehensive overview of all the Gang of Four (GoF) design patterns, as well as modern-day variations and adjustments.
Provides a comprehensive guide to C++ templates. It great resource for experienced C++ developers who want to learn about the latest techniques and best practices for using templates.
Provides a comprehensive guide to C++ concurrency. It great resource for experienced C++ developers who want to learn about the latest techniques and best practices for developing concurrent applications.
Provides a comprehensive guide to C++ template metaprogramming. It great resource for experienced C++ developers who want to learn about the latest techniques and best practices for using template metaprogramming.
Provides a collection of 101 rules, guidelines, and best practices for writing C++ code. It great resource for experienced C++ developers who want to learn about the latest techniques and best practices for writing clean, maintainable, and efficient code.
Provides a comprehensive overview of design patterns in Java. It great choice for experienced Java developers who want to learn about the latest techniques and best practices for using design patterns in their code.
Provides a more accessible and humorous introduction to design patterns in Java. It great choice for beginners who want to learn about design patterns without getting bogged down in technical details.
Provides a collection of 57 specific ways to improve your Java code. It great resource for experienced Java developers who want to learn about best practices and avoid common pitfalls.
Provides a comprehensive guide to Java concurrency. It great resource for experienced Java developers who want to learn about the latest techniques and best practices for developing concurrent applications.
Provides a more accessible and humorous introduction to design patterns, using real-world examples and analogies. It great choice for beginners who want to learn about design patterns without getting bogged down in technical details.

Share

Help others find this course page by sharing it with your friends and followers:
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser