As usual, let's start with you, abstraction first, so we have this interface called service, which
has only one method to be implemented, which will download the file that the client application needs.
So let's go to the implementation.
So we have this file download service, which has the name of the file as a property, which is set
at the level of a constructor.
And also we have the implementation for the download file.
So for the sake of simplicity, I just stick with the system, this system, our printer and statements
here so you can see that whenever this method is invoked, the name of the file will be printed as well
as this this message over here.
Let's take a look at the proxy.
So the proxy is using composition it has and as a property, the file download service and also the
file name.
So basically, you construct the proxy as you do construct a file download service using the family
and the download file will do some surprisingly, it will do some checks to see if the client has access
to this resource and the access is granted, then it will go to check if the file download service is
no.
And if it's not, it will proceed to download the file.
If it's if the file download services null, then it will create another instance of this resource here.
So let's see the client application.
So here we have a file, a very simple the text file and the service, as you can see, will take the
form of a proxy service.
So this will eventually let's allow the client application to download the needed files.
So let's see this in action.
So as you can see, the check is performed to see if the resource can be accessed, if the access is
granted, then the file is loaded and then the file is being downloaded.
This is a very, very simple implementation of the proxy pattern where you deal with some of the security
aspects of the backend system that serves the files.
Of course, this is this is not covered in this code here.
There are just a very simple system of print and statements.
But this is just to give you an insight on how to use the proxy in a real life scenario.
So that's it.
This was the last tutorial on the structural design patterns in the next module.
We are going to discuss about the behavioral design patterns.
So see you in the next video.