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

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…

Contents