Greetings everyone who watching this episode. My name Andrii and representing channel MLA Automation. Who is first time hit please on Subscribe button, and Like button. On this channel you will be able to find interesting topics in programming. Currently we are learning PHP and today's episode related to serious of videos about Design Patterns in PHP.
So we going to bring on the table next pattern in Structural group and it called - Proxy
1:29 - Analogy:
You can open a door with an electronic lock using an access card or a button to bypass the security system. That is, the main functionality of the door is to open, and on top of it there may be some other functionality - a "substitute".
In a nutshell
By using the Proxy pattern, a class represents the functionality of another class.
Wikipedia
In its most general form, a surrogate is a class that functions as an interface to something. It is a wrapper or agent object called by a client to gain access to another, "real" object. The “surrogate” can simply forward requests to the real object, or it can provide additional logic: data caching during intensive operations or resource consumption by the real object; checking preconditions before invoking the execution of operations by this object.
Example:
Link on the Code for Example(above):
[ Ссылка ]
What the difference between Decorator vs Proxy:
Although decorators can have similar implementations as proxies, decorators have a different purpose.
A "decorator" adds one or more responsibilities to an object, whereas a proxy controls access to an object.
Proxies vary in the degree to which they are implemented like a decorator. A protection proxy might be implemented exactly like a decorator. On the other hand, a remote proxy will not contain a direct reference to its real subject but only an indirect reference, such as "host ID and local address on host." A virtual proxy will start off with an indirect reference such as a file name but will eventually obtain and use a direct reference.
Reference on Resource
[ Ссылка ]
[ Ссылка ]
SUBSCRIBE TO CHANNEL:
[ Ссылка ]
Facebook - [ Ссылка ]
Twitter - [ Ссылка ]
Don't forget pls to click on 'Like', its giving additional motivation to work on channel.
Thank you for watching, for subscription and see you soon.
#mlaautomation #designpatterns #proxy #oopphp #php #tutorial #guide #phplessons #interview #questions #answers #devleoper #programmer #learncoding
Ещё видео!