1 00:00:02,150 --> 00:00:09,020 The proxy battle is our last structural design pattern proxies are usually entities that represent other 2 00:00:09,020 --> 00:00:12,560 entities and the proxy design pattern does just that. 3 00:00:12,920 --> 00:00:15,240 It acts as another object. 4 00:00:15,650 --> 00:00:20,950 It is basically a class that serves as an interface between a client application and another object. 5 00:00:22,570 --> 00:00:25,120 The typical usages for the proxy button are. 6 00:00:26,350 --> 00:00:32,800 When we need to create a rapport to cover the main object's complexity from the client or when we need 7 00:00:32,800 --> 00:00:38,350 to ensure the security of a given resource and we need a proxy to check if the client is allowed to 8 00:00:38,350 --> 00:00:41,410 access a resource that the proxy is representing. 9 00:00:43,070 --> 00:00:45,870 This is a typical UML diagram to the proxy battle. 10 00:00:47,400 --> 00:00:52,740 In our code, we would have a server which serves one file to the client application. 11 00:00:53,760 --> 00:01:00,540 However, the client will call the server directly, but it will ask the proxy for the file, the proxy 12 00:01:00,540 --> 00:01:06,290 will ensure that the client is entitled to receive the file, and if yes, then it will access the original 13 00:01:06,300 --> 00:01:10,160 resource on the client's behalf and will serve the file to the client. 14 00:01:11,610 --> 00:01:13,740 The witnesses for this pattern are. 15 00:01:15,290 --> 00:01:21,020 We can have only one proxy, therefore, if you want to do error handling, security handling or one 16 00:01:21,020 --> 00:01:26,960 to manage other aspects of dealing with the original resource, then you will have to do it in a single 17 00:01:26,960 --> 00:01:27,410 class. 18 00:01:28,790 --> 00:01:33,580 Also, it provides another layer of abstraction which can increase the complexity of the program. 19 00:01:34,890 --> 00:01:37,860 Let's have a look at the implementation of this pattern in the code.