Comparison
Adapter patternvsWrapper
Adapter pattern
the library's method was called differently and returned the wrong shape, so you wrote a class that speaks both.
A wrapper that converts one interface into another the caller already expects, so two things that were not designed together can work together. The intent is incompatibility, and that is what separates it from the other three wrappers: the adapter's interface is deliberately different from the thing it wraps. It is the pattern that keeps a third-party SDK from spreading through a codebase, which is the same argument the anti-corruption layer makes at the service boundary.
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 →