Proxy or decorator?
transcript
Two classes. Both have exactly the same interface as the object they wrap. One is a proxy. One is a decorator. The code looks almost identical. So how do you tell them apart?
A proxy controls access to the real object. Create it later, check who is asking, remember an answer. A decorator adds a responsibility. A retry. A log line. A surge fee.
Look at who builds what. A proxy often creates and owns the real object itself. A decorator is chosen by the client, and stacked in any order. The book says a protection proxy can look exactly like a decorator.
The third look-alike is different. An adapter changes the interface, so a class you can't edit still fits. A proxy and a decorator both keep the interface the same. That's why purpose decides.
Is it access, a new duty, or translation? So ask what the wrapper is for.
Full breakdown in the lecture.