1 00:00:02,150 --> 00:00:08,840 Let's focus first on the program that will receive the facade, so basically we have a single interface 2 00:00:08,840 --> 00:00:16,100 with only one method to be implemented and we have to object to the computer object, which will implement 3 00:00:16,100 --> 00:00:23,900 this reform operation method with a sound argument and a robot object which will do the same, but with 4 00:00:23,900 --> 00:00:26,720 a different it will output the different tacks here. 5 00:00:26,960 --> 00:00:34,070 So this is an oversimplification, but imagine if you would have had a complex and very complex program 6 00:00:34,070 --> 00:00:38,960 here with many other methods, many objects with a very complicated lifecycle. 7 00:00:39,800 --> 00:00:46,490 It's not it's not a good practice to to leave to to expose this program to a client application. 8 00:00:46,670 --> 00:00:54,980 It's better to have a facade like an interface that will manage all the operations and will will do 9 00:00:54,990 --> 00:01:01,610 the will simplify all on the structure of the internal structure, will hide all the implementation 10 00:01:01,610 --> 00:01:09,820 complexities and will expose just these operations that the client application is interested in. 11 00:01:10,160 --> 00:01:13,240 So let's see this for. 12 00:01:13,940 --> 00:01:16,090 So basically, it's using composition. 13 00:01:16,280 --> 00:01:22,160 It has two objects, the computer and the robot object into a constructor itself. 14 00:01:22,160 --> 00:01:25,250 It's initializing those those objects. 15 00:01:25,580 --> 00:01:32,060 And it has two methods for a computer to perform operation and for the robot to perform operation. 16 00:01:32,600 --> 00:01:39,440 So this is a very simple way to hide all the complexities of the underlying program. 17 00:01:40,620 --> 00:01:46,280 And this is the main the main usage for the facade pattern and let's see destination's. 18 00:01:46,280 --> 00:01:51,920 So in the main method here, we create a facade class, which will create an instance of the computer 19 00:01:51,920 --> 00:01:59,540 at the robot class, and it will will have two lines here for performing the operations, using the 20 00:01:59,540 --> 00:02:00,690 computer and the robot. 21 00:02:01,010 --> 00:02:02,550 So let's see this in action. 22 00:02:02,900 --> 00:02:07,190 So as you can see, the two lines are outputted here in the console. 23 00:02:08,440 --> 00:02:09,990 Everything works as expected. 24 00:02:10,220 --> 00:02:17,180 So instead of creating the objects yourself and supposedly doing some other complicated stuff, first 25 00:02:17,660 --> 00:02:22,460 you have the facade class, which contains the final the end result. 26 00:02:22,460 --> 00:02:22,650 Right. 27 00:02:22,670 --> 00:02:30,950 That method that will perform the all the action, all the although all the flow of the application 28 00:02:31,070 --> 00:02:35,420 and it will output the end result using a single method. 29 00:02:35,420 --> 00:02:45,790 So much, much easier than having to call all the underlying program objects and dealing with the emotional 30 00:02:45,800 --> 00:02:47,930 complexity of that of that program. 31 00:02:48,890 --> 00:02:49,920 So that's about it. 32 00:02:50,750 --> 00:02:55,650 This is a very simple design pattern to explain, Jean. 33 00:02:55,700 --> 00:02:59,330 And next story where we are going to discuss about the flyweight pattern.