I\'ve been reading both definitions and they seem quite the same. Could anyone point out what are their differences?
Thanks
Adapter makes two interfaces work together.
Facade exposes a single class to a higher, and more limited level. For example, a view model facade may only expose certain read only properties of a lower level class.
I've been reading both definitions and they seem quite the same.
Really ?
I have noticed that the term Adapter is sometimes used to describe what is in fact a Stategy, maybe because the word is more expressive.
For example, in Zend Framework, all the Adapter classes are in fact implementations of the Strategy pattern, because they only wrap native code behind classes, to have several behaviours.
Adapters are often used to wrap legacy or "old-style" code.
Honestly, many patterns could be implemented the same way programmatically -- the difference is in intent.
The Adapter design pattern is meant to 'translate' the interface of one or more classes into an interface that the client expects to use -- the adapter would translate the calls to the expected interface into the actual interface the wrapped classes use.
The Facade pattern is used when a simpler interface is wanted (and again, could be implemented the same way by wrapping the offending classes.) You wouldn't say you're using a facade when the existing interface is incompatible, just when you need to make it more readable, less poorly-designed, etc.
The main goal of the Facade pattern is to make the class or subsystem easier to use, while the main goal of the Adapter pattern is to adjust the interface to what the client expects.