We will use the simple program that generates a report for us as an example.
So let's study a bit abstraction first so we have the simple interface here that has only one method
that doesn't return anything.
And this interface is implemented in this class called general report operation.
So this is basically the command, the equivalent of a command in the terminology of the command pattern.
Of course, you can have multiple commands, but for the sake of simplicity, just stick with having
a single command coded here.
So this is the receiver object.
And you can see the pattern is making use of composition to store a reference to it and execute method
will create an instance of the receiver object and it will call the generic method from from from the
object itself.
Let's take a look at the receiver object.
You can see that the only outputs some lines in the console.
So it's supposed to show when the report is being generated and when the report has been generated,
when the process basically is is finished.
This is the Invoker class.
So this knows how to execute the commands.
So it has this execute operation method here.
The execute operation will take on object of this interface as an argument, and it will call the execute
method that is inside of this object.
Let's take a look at the grant application.
So the current application here, we create new Invoker object.
And here, as you can see, we create a new general report operation because this is the only command
that we can run as part of this program.
So this will eventually call this execute method here.
Right.
So let's start let's run this.
And as you can see, we have the desired output here.
So it basically ran the commands for generating the report.
That's it for this pattern.
Join me in the next video where we are going to discuss about the interpreter, Peter.