1 00:00:01,700 --> 00:00:05,760 We will use the simple program that generates a report for us as an example. 2 00:00:05,930 --> 00:00:14,510 So let's study a bit abstraction first so we have the simple interface here that has only one method 3 00:00:14,510 --> 00:00:15,750 that doesn't return anything. 4 00:00:15,980 --> 00:00:21,720 And this interface is implemented in this class called general report operation. 5 00:00:22,160 --> 00:00:27,930 So this is basically the command, the equivalent of a command in the terminology of the command pattern. 6 00:00:28,250 --> 00:00:33,680 Of course, you can have multiple commands, but for the sake of simplicity, just stick with having 7 00:00:33,680 --> 00:00:35,720 a single command coded here. 8 00:00:36,020 --> 00:00:39,080 So this is the receiver object. 9 00:00:39,200 --> 00:00:47,000 And you can see the pattern is making use of composition to store a reference to it and execute method 10 00:00:47,240 --> 00:00:55,550 will create an instance of the receiver object and it will call the generic method from from from the 11 00:00:55,550 --> 00:00:56,420 object itself. 12 00:00:56,780 --> 00:00:58,600 Let's take a look at the receiver object. 13 00:00:58,610 --> 00:01:02,770 You can see that the only outputs some lines in the console. 14 00:01:03,020 --> 00:01:09,140 So it's supposed to show when the report is being generated and when the report has been generated, 15 00:01:09,170 --> 00:01:11,460 when the process basically is is finished. 16 00:01:12,350 --> 00:01:13,900 This is the Invoker class. 17 00:01:14,210 --> 00:01:17,780 So this knows how to execute the commands. 18 00:01:17,780 --> 00:01:20,840 So it has this execute operation method here. 19 00:01:21,650 --> 00:01:29,780 The execute operation will take on object of this interface as an argument, and it will call the execute 20 00:01:29,780 --> 00:01:33,080 method that is inside of this object. 21 00:01:33,860 --> 00:01:35,550 Let's take a look at the grant application. 22 00:01:35,570 --> 00:01:40,790 So the current application here, we create new Invoker object. 23 00:01:40,940 --> 00:01:46,850 And here, as you can see, we create a new general report operation because this is the only command 24 00:01:46,850 --> 00:01:50,160 that we can run as part of this program. 25 00:01:50,930 --> 00:01:57,000 So this will eventually call this execute method here. 26 00:01:57,380 --> 00:01:57,680 Right. 27 00:01:57,980 --> 00:02:00,650 So let's start let's run this. 28 00:02:00,650 --> 00:02:04,540 And as you can see, we have the desired output here. 29 00:02:04,550 --> 00:02:09,830 So it basically ran the commands for generating the report. 30 00:02:11,120 --> 00:02:12,840 That's it for this pattern. 31 00:02:13,040 --> 00:02:18,470 Join me in the next video where we are going to discuss about the interpreter, Peter.