1 00:00:00,960 --> 00:00:06,360 As usual, let's start with you, abstraction first, so we have this interface called service, which 2 00:00:06,360 --> 00:00:12,540 has only one method to be implemented, which will download the file that the client application needs. 3 00:00:12,870 --> 00:00:15,820 So let's go to the implementation. 4 00:00:15,850 --> 00:00:23,430 So we have this file download service, which has the name of the file as a property, which is set 5 00:00:23,430 --> 00:00:24,860 at the level of a constructor. 6 00:00:25,110 --> 00:00:27,900 And also we have the implementation for the download file. 7 00:00:27,930 --> 00:00:34,650 So for the sake of simplicity, I just stick with the system, this system, our printer and statements 8 00:00:34,650 --> 00:00:43,230 here so you can see that whenever this method is invoked, the name of the file will be printed as well 9 00:00:43,230 --> 00:00:45,070 as this this message over here. 10 00:00:45,390 --> 00:00:47,250 Let's take a look at the proxy. 11 00:00:47,250 --> 00:00:57,270 So the proxy is using composition it has and as a property, the file download service and also the 12 00:00:57,270 --> 00:00:57,750 file name. 13 00:00:58,680 --> 00:01:05,400 So basically, you construct the proxy as you do construct a file download service using the family 14 00:01:05,730 --> 00:01:12,930 and the download file will do some surprisingly, it will do some checks to see if the client has access 15 00:01:12,930 --> 00:01:19,860 to this resource and the access is granted, then it will go to check if the file download service is 16 00:01:19,860 --> 00:01:20,160 no. 17 00:01:20,310 --> 00:01:24,680 And if it's not, it will proceed to download the file. 18 00:01:24,690 --> 00:01:31,410 If it's if the file download services null, then it will create another instance of this resource here. 19 00:01:31,800 --> 00:01:33,470 So let's see the client application. 20 00:01:33,480 --> 00:01:42,450 So here we have a file, a very simple the text file and the service, as you can see, will take the 21 00:01:42,450 --> 00:01:45,100 form of a proxy service. 22 00:01:45,540 --> 00:01:53,940 So this will eventually let's allow the client application to download the needed files. 23 00:01:53,940 --> 00:01:55,500 So let's see this in action. 24 00:02:00,490 --> 00:02:09,940 So as you can see, the check is performed to see if the resource can be accessed, if the access is 25 00:02:09,940 --> 00:02:14,090 granted, then the file is loaded and then the file is being downloaded. 26 00:02:15,580 --> 00:02:23,650 This is a very, very simple implementation of the proxy pattern where you deal with some of the security 27 00:02:23,650 --> 00:02:27,400 aspects of the backend system that serves the files. 28 00:02:28,270 --> 00:02:32,680 Of course, this is this is not covered in this code here. 29 00:02:32,830 --> 00:02:37,150 There are just a very simple system of print and statements. 30 00:02:37,360 --> 00:02:43,580 But this is just to give you an insight on how to use the proxy in a real life scenario. 31 00:02:44,200 --> 00:02:45,250 So that's it. 32 00:02:45,430 --> 00:02:52,630 This was the last tutorial on the structural design patterns in the next module. 33 00:02:52,660 --> 00:02:56,550 We are going to discuss about the behavioral design patterns. 34 00:02:56,550 --> 00:02:59,020 So see you in the next video.