From the course: C++ Design Patterns: Behavioral
Unlock the full course today
Join today to access over 24,100 courses taught by industry experts.
The Command pattern - C++ Tutorial
From the course: C++ Design Patterns: Behavioral
The Command pattern
- [Instructor] Okay, it's time for our second design pattern which is called the command pattern. The command pattern can help us greatly reduce coupling between different classes in our application as well as make certain pieces of functionality much more reusable as we'll see. And it does this by expressing the different events that can occur in our application as their own classes. And we'll look at the details of this shortly. So in order to get a better idea of how the command pattern works, let's take a look at an example where this pattern might be helpful. So in most applications that we write any changes that we want to make usually take place by one piece of code directly calling another piece of code. So as an example let's say that we're building a drawing application of some sort, and that this application has a clear canvas button that deletes all the lines, colors, et cetera, from the screen. Now this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
The Chain of Responsibility pattern3m 57s
-
(Locked)
Implementing the Chain of Responsibility pattern7m 27s
-
(Locked)
Create Chain of Responsibility handlers7m 35s
-
(Locked)
The Command pattern3m 56s
-
(Locked)
Implementing the Command pattern4m 14s
-
(Locked)
Increasing code reuse with commands3m 28s
-
(Locked)
The Mediator pattern4m 13s
-
(Locked)
Implementing the Mediator pattern9m 1s
-
(Locked)
Using the Mediator from inside other classes6m 51s
-
(Locked)
The Observer pattern2m 54s
-
(Locked)
Creating publishers7m 48s
-
(Locked)
Creating subscribers5m 34s
-
(Locked)
Project: Create a group-chat program7m 32s
-
(Locked)
Challenge: Apply the Command pattern1m 2s
-
(Locked)
Solution: Apply the Command pattern6m 26s
-
-
-
-