Adapter Pattern vs Facade Pattern
People think an adapter and a facade are the same wrapper. An adapter wraps one thing so it fits a shape another part expects. It changes the interface, but not how much there is to it. A facade puts one simple front over many parts. It makes the interface smaller, so callers have less to learn. You use an adapter to make things fit, and a facade to make them easy.
Adapter Pattern
A wrapper that lets one piece of code fit another.
The adapter pattern wraps one piece of code so it looks like another. It is used when two parts should work together but expect different shapes. The adapter sits in between and turns each call into the form the other side needs. Neither side has to change. It is common when you plug in an outside library or an old system.
Facade Pattern
One simple front for many parts. Callers need just one call.
The facade pattern puts one simple interface in front of a group of complex parts. Callers use a few easy methods on the facade. The facade then calls the many classes behind it in the right order. The parts behind it still exist and can be used directly if needed. It hides detail, but it does not change what the parts do.
In one line
- Adapter Pattern
- A wrapper that lets one piece of code fit another.
- Facade Pattern
- One simple front for many parts. Callers need just one call.