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 Structural 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. 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.
-
The intent, structure of the pattern is explained through UML class diagram.
-
Basic implementation details of the pattern are explained.
-
The pattern is implemented in a simple example.
-
You get familiar with the overall implementation of the pattern.
-
Another example is introduced that has design issues the pattern aims to resolve.
-
We examine the issues and refactor the code by applying the design pattern step by step.
-
Alternative scenarios & examples are explained along with differences between them. You also learn how to decide between different alternatives.
-
I discuss the pattern in context of C++ and how to tweak it for performance, reusability & maximum flexibility.
-
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
Course introduction.
Understand what a pattern means.
A quick primer on UML class diagrams.
Understand the basics of SOLID principles. This lecture explains the single responsibility & open closed principle.
Understand the liskov substitution principle.
This lecture explains the interface segregation & depending inversion principle.
Gives an overview of the structural patterns.
Download the slide deck used in the videos.
Note: The slide deck is password protected & must be opened as read-only when prompted for a password.
Adapter
Introduction to the Adapter Pattern.
Basic code example of the pattern and the participants & their interactions.
Game input example.
Understand why we need the adapter pattern.
Object adapter implementation in the game.
Example of how to implement a class adapter.
Pros & cons of the adapter pattern.
Facade
Introduction to the facade pattern.
Basic implementation of the facade.
Using Console API to write colored text.
Issues with the implementation.
Implementing the Console class as a facade.
Using the Console class from the client code.
Adding support for Linux.
Pros & cons of the facade pattern.
Proxy
Introduction to the proxy pattern.
Basic C++ implementation of the proxy.
Introduction to the virtual proxy.
Implementing the Imageviewer application.
Applying the virtual proxy.
Protection proxy introduction.
Creating the repository example.
Applying the protection proxy.
Introduction to the remote proxy.
Sprite animator example.
Using the remote proxy as a COM component.
Smart pointer as a proxy.
Pros & cons of using the proxy.
Decorator
Introduction to decorator pattern.
Basic example of the decorator.
Adding the abstract Decorator class.
Explanation of the Streams application & implementation of file stream classes.
Explanation of how to add buffering to streams.
Adding the BufferedStream class.
Adding encrypting & compression support to streams.
Using composition instead of inheritance.
Adding the Decorator abstract class in both input & output stream class hierarchies.
Discussion on the types of decorators.
Explanation & implementation of static decorator.
Explanation & implementation of functional decorator.
Pros & cons of the decorator pattern.
Composite
Introduction to composite pattern.
Discussion of the intent & implementation overview.
Basic implementation of the composite.
Explanation of the user-interface example.
Adding the UI class hierarchy.
Discussion of the issues in the example.
Adding support for parent pointer.
Pros & cons of using the composite pattern.
Bridge
Introduction to the bridge design pattern.
Intent of the pattern and overview of the implementation.
Basic implementation of the bridge pattern.
Discussion of the Shape hierarchy and implementation of the Line class.
Adding the Shape base class.
Adding more shape classes.
Adding support for rendering through OpenGL.
Discussion of the issues with the design.
Implementing the bridge pattern in the shape drawing application.
Discussion of the handle-body idiom.
Creating the String class.
Implementing sharing for String objects.
Discussion of the PIMPL idiom.
Implementing PIMPL to remove compilation dependencies.
Discussion of the static bridge.
Pros & cons of using the pattern.
Flyweight
Introduction to the flyweight pattern.
Discussion of the intent & overview of the implementation.
Basic implementation of the flyweight.
Explanation of the 3d models in game.
Discussion of the issues and their resolution.
Adding the Car class.
Creating the String class.
Adding StringInfo for sharing internal strings.
Completing the string interning implementation.
Using the Boost.Flyweight for interning.
Pros & cons of using the flyweight pattern.