jargon

Comparison

Proxy patternvsWrapper

Proxy pattern

the object looks and behaves exactly like the real one, and its whole job is deciding whether the call gets through.

A wrapper with the same interface as its subject whose purpose is to control access to it — checking permission, deferring creation, or standing in for something remote. It shares its shape with the decorator and differs in intent: a decorator adds behaviour the caller wants, a proxy manages access the caller should not have to think about. Proxies typically control the subject's lifetime as well, where decorators are handed one already made.

Full entry →

Wrapper

the object holds another object and forwards most calls to it, and which pattern that is depends entirely on why.

The shape shared by adapter, decorator, proxy and facade: an object that holds another and passes work through. Because the code looks nearly identical in all four, the name is chosen by intent — to change an interface, to add behaviour, to control access, or to simplify a subsystem — and that is exactly what the interview question is testing. Calling something a wrapper is honest when the intent is genuinely none of the four.

Full entry →

Related comparisons